AJAX 在 error 時顯示錯誤訊息
在 AJAX error 時,跳出 alert
$.post("test.php", function(data) { alert("Data Loaded: " + data); }) .error(function() { alert("error"); })
如何秀出 error message
error: function(xhr, status, error) { var err = eval("(" + xhr.responseText + ")"); alert(err.Message); }
合併起來的例子
$.post("test.php", function(data) { alert("Data Loaded: " + data); }).error: function(xhr, status, error) { var err = eval("(" + xhr.responseText + ")"); alert(err.Message); }
php - How to get the jQuery $.ajax error response text? - Stack Overflowhttps://stackoverflow.com/questions/1637019/how-to-get-the-jquery-ajax-error-response-textjavascript - jQuery.post() failure callback function? - Stack Overflow https://stackoverflow.com/questions/6046898/jquery-post-failure-callback-function
沒有留言:
張貼留言