How can I determine why the jQuery ajax $ .post request was not successful?

I am trying to determine, based on the result of this call, if it was successful. successFunction not called, so I assume it is not. How to find out what went wrong?

 xmlRequest = $.post("/url/file/", { 'id' : object.id }, successFunction, 'json'); 

Am I using an xmlRequest object?

+4
source share
2 answers

You can use:

 $.ajax({ url:"/url/file/", dataType:"json" data:{ 'id' : object.id } error:function(request){alert(request.statusText)} success:successFunction }) 
+9
source

You can use the $ .ajaxComplete () and / or $ .ajaxError () methods to attach the function to these events. I also recommend using a Firefox browser with a Firebug connection, you can get a lot of information about requests and responses.

+5
source

Source: https://habr.com/ru/post/1276654/


All Articles