开发者

jQuery ajaxSubmit calls always returning a 0 response code with response.statusText = 'n/a'

Background: jquery 1.5.2, ruby on rails.

The major issue seems to be that I'm getting a 0 response code regardless of what the web server tells me it is returning.

I have an application that returns 开发者_如何转开发a 422 when validation on a model fails, but for some reason the success function is getting called every time.

     $("#form").ajaxSubmit({
      dataType: 'json',
      success: function(data, status, response) {
        // stuff
      },
      error: function(data) {
        // stuff
      }
     });

When I console.log everything, this is what I see:

POST http://site/favicons 422 (Unprocessable Entity)
data: Object
  favicon: "Image must be 16x16 pixels"
  __proto__: Object

status: success

response:Object
abort: function (status) {
aborted: 0
getAllResponseHeaders: function () {}
getResponseHeader: function (header){
responseText: "{"favicon":"Image must be 16x16 pixels"}"
responseXML: null
setRequestHeader: function () {}
status: 0
statusText: "n/a"
__proto__: Object


The issue was because I was doing a file upload, which always returns 0 and n/a.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜