1$.ajax({
2 type: "post", url: "/SomeController/SomeAction",
3 success: function (data, text) {
4 //...
5 },
6 error: function (request, status, error) {
7 alert(request.responseText);
8 }
9});
10
1$.ajax({
2 url: 'some_unknown_page.html',
3 success: function (response) {
4 $('#post').html(response.responseText);
5 },
6 error: function (jqXHR, exception) {
7 var msg = '';
8 if (jqXHR.status === 0) {
9 msg = 'Not connect.\n Verify Network.';
10 } else if (jqXHR.status == 404) {
11 msg = 'Requested page not found. [404]';
12 } else if (jqXHR.status == 500) {
13 msg = 'Internal Server Error [500].';
14 } else if (exception === 'parsererror') {
15 msg = 'Requested JSON parse failed.';
16 } else if (exception === 'timeout') {
17 msg = 'Time out error.';
18 } else if (exception === 'abort') {
19 msg = 'Ajax request aborted.';
20 } else {
21 msg = 'Uncaught Error.\n' + jqXHR.responseText;
22 }
23 $('#post').html(msg);
24 },
25});
26