How do I use alert() for errors?
How do I alert() an error when my server code returns false?
$("#editme1").editInPlace({
url: 'server.php',
error_sink: function(editme1, erro开发者_StackOverflow中文版rString) { alert(errorString); } <----Maybe this?
});
what do you want to do exactly , if you are using ajax to call server side you can do in the error block. see the documentation here http://api.jquery.com/jQuery.ajax/
You can use the error
callback, like this:
$("#editme1").editInPlace({
url: 'server.php',
error: function(xhr) { alert("Server error: " + xhr.responseText); }
});
Unfortunately the author didn't do a very good job here, he ignored the other very useful parameter error
parameters on the $.ajax()
error callback (textStatus
and errorThrown
).
So instead of using his error
callback at all I'd use the global .ajaxError()
handler, for example:
$(document).ajaxError(xhr, options, error) {
alert("An error occured when fetching content: " + error);
});
Then don't specify anything in the plugin options for this:
$("#editme1").editInPlace({ url: 'server.php' });
精彩评论