Explore Courses Blog Tutorials Interview Questions
0 votes
in DevOps and Agile by (19.7k points)

Within an ajax request how can the error callback be tested? Is it possible to simulate a network connection error?


        url: "myUrl",       

        type: 'post',

        dataType : "json",

        data : ({



        success : function(jsonSaveResponse) {  


        error: function (xhr) {



1 Answer

0 votes
by (62.9k points)

You could simply put an incorrect URL into the URL attribute of the AJAX call., something like this:


    header("HTTP/1.0 404 Not Found");


    //the rest of your code

You can simply comment it out later when you're done testing your error function.

Browse Categories