0 votes
1 view
in DevOps and Agile by (19.8k 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 (63.4k 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.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !