javascript - How can we call Ajax "error: function()" function manually from success function? -
how can call error: function manually success:function ? possible ?
success: function(data) { response($.map(data, function(item) { if (item != "some value") { // call error:function here } return item; })) }, error: function(xhr, status, error) { var err = eval("(" + xhr.responsetext + ")"); alert(err.message); }
like this:
success: function(data) { response($.map(data, function(item) { if (item != "some value") { onerror(...) } return item; })) }, error: onerror var onerror = function(xhr, status, error) { var err = eval("(" + xhr.responsetext + ")"); alert(err.message); }
by way, use eval never idea.
Comments
Post a Comment