【问题标题】:No response status in ajax call not sure whyajax调用中没有响应状态不知道为什么
【发布时间】:2013-05-31 19:55:29
【问题描述】:

我对我的 spring mvc 应用程序进行了以下 ajax 调用..

        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);
             }
        });

我的 mvc 控制器:

@RequestMapping(value = "/dashboard", method = RequestMethod.GET)
@ResponseStatus(value=HttpStatus.OK)
public String dashboard(Model model, HttpServletRequest req) {

    int i = 0;

    return "login";
}   

我的问题是我不明白为什么这没有产生我期望的响应状态?...当我在 javascript 中检查 response.status 时,它给了我未定义?...知道为什么

【问题讨论】:

    标签: javascript jquery jquery-mobile


    【解决方案1】:

    JQuery .get docs。看起来您的成功回调中的“响应”对象实际上是“登录”。因此,您实际上是在尝试执行“登录”.status。

    【讨论】:

      猜你喜欢
      • 2013-03-24
      • 2015-03-08
      • 1970-01-01
      • 2020-02-09
      • 1970-01-01
      • 2017-12-30
      • 2021-09-18
      • 2015-10-31
      • 1970-01-01
      相关资源
      最近更新 更多