ajax调用中没有响应状态,不确定原因

No response status in ajax call not sure why

本文关键字:不确定 状态 响应 调用 ajax      更新时间:2023-09-26

我有以下ajax调用这是我的spring mvc应用程序..

        alert("ready");
        $.ajax({
            type: "GET",
            url: document.location.toString()+ "/dashboard",
            success: function(response) {
                alert(response);
                alert(response.status);                                             
                $("#frameBody").contents().find("html").html(response);
                // we have the response
                if(response.status == "SUCCESS") {
                    alert(response);
                    // do nothing..
                    // check for no content... if there is content... replace iframe
                    // $("#frameBody").attr('src', jsonObj.url);
                    // $(""#frameBody").contents().find("html").html(response);
                }
                else {  
                    // do nothing yet
                }
             },
             error: function(e){
                $("#errors").attr("style", "display:inline")
                $('#errors').html(e.responseText);
                window.setTimeout("fadeErrorsDiv();", 5000);
             }
        });

my MVC controller:

@RequestMapping(value = "/dashboard", method = RequestMethod.GET)
@ResponseStatus(value=HttpStatus.OK)
public String dashboard(Model model, HttpServletRequest req) {
    int i = 0;
    return "login";
}   

我的问题是,我看不出为什么这没有产生我期望的响应状态?当我检查响应时,结果是undefined。javascript中的状态?知道为什么

参见JQuery .get文档。看起来你成功回调中的"response"对象实际上是"login"。因此,您实际上是在尝试执行"login".status。