jQuery ajax()调用失败

I am writing a web-based application that makes a call to server to update a particular object in the server, from a REST-ful application.

This is the javascript code that I have written.

var sendUrl = url + "v1/items/" + itmId;
$.ajax({
    "type": "PUT",
    "url": sendUrl,
    //"data": {"name": nameVal, "description": descVal},
    "success": function() {
        alert('hai');  //refreshItems();
    },
    "complete": function (jqXHR, textStatus) {
        alert (textStatus);
    }
});

When this code is executed, the server did not receive any request. The browser did not show any update.

I am using Google Chrome as my browser. So, I looked into Chrome's Javascript Console, the console showed this error:

Error from Chrome's Console

Are there any possible solutions to this problem?


Edit:

As suggested in one of the comments, I tried looking into Network Panel. It seems it is not making a call to Server.

This is the screenshot of this particular request: enter image description here

The image is very small. The status is "(failed)" and Type is Pending

If Server does not have PUT configured, it would result in an Internal Server Error. So, that is not happening here.


Edit

After trying the suggestion given in the answer,

This is the code:

var sendUrl = url + "v1/items/" + itmId;
$.ajax({
    "type": "PUT",
    "url": sendUrl,
    //"data": {"name": nameVal, "description": descVal},
    }).done(function ( ) {
        alert('OK');
    }).fail(function ( jqXHR, textStatus, errorThrown ) {
        console.log(jqXHR);
        console.log(textStatus);
        console.log(errorThrown);
    });

Here are the objects that has been logged:

enter image description here

查看全部
weixin_33739523
weixin_33739523
2013/02/21 00:22
  • ajax
  • jquery
  • 点赞
  • 收藏
  • 回答
    私信

1个回复