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"); });
Comments
Post a Comment