javascript - How to determine error if using $.post() or $.get() -


i know how handle errors $.post or $.get

$.post(url,data,function(data,status,xhr),datatype) $.get(url,data,function(data,status,xhr),datatype) 

without using $.ajax has error handler.

$.ajax({     url: url,     type: $(this).attr("method"),     datatype: "json",     data: data,     processdata: false,     contenttype: false,     success: function (data, status)     {      },     error: function (xhr, desc, err)     {       } });    

jquery's post , get promisses, can chain functions done, fail , always on these:

var jqxhr = $.post( "example.php", function() {     alert("success"); }) .done(function() {     alert("second success"); }) .fail(function() {     alert("error"); }) .always(function() {     alert("finished"); }); 

or later, varibale:

jqxhr.always(function() {     alert("second finished"); }); 

see documentation.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -