Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Handling ajax call errors (404, 500, etc.)

$
0
0

Hi,

I'm using $.ajax method to send some information (json) to the server. But I dont have the server function yet. So it will return 404 Not Found error.

The thing is I want to handle this 404 error myself so the browser won't raise an error for it.

My partial code is:

$.ajax({
            url: url,
            data: model,
            type: "POST",
            dataType: "json",
            contentType: "application/json utf-8",
            success: function (result) {
                console.log(result);
            },
            error: function (xhr, responseText) {
                console.log("The ajax call returned error " + xhr.status + ": " + xhr.statusText);
            }
        });

But when I run the code I see two errors on console. One is my "The ajax call...", and the other one is from the Google Chrome which is even before my error handler.

POST http://localhost:5785/Admin/ut  404    (Not Found) -- I don't want to see this one --       jquery-2.0.3.js:7845

The ajax call returned error  404: Not Found                                                             admin.js:165

How can I manage that?


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>