1

success funtion not called even i got the 200 status code in network tab developer tool.

var isServiceUp=false;
    do{
            var response=jQuery.ajax({
                url : "https://127.0.0.1:18647/dcs/dcs_6200808/",
                method : "POST",
                //data : formData,
                //cache : false,
                //async : false,
                success : function(data, textStatus, jqXHR){
                    //debugger;
                    console.log("hey i am up");
                    isServiceUp=true;
                    },
                error : function(jqXHR, textStatus, errorThrown){

                }
            });

    }while(!isServiceUp)
  • Did the error function get called instead? – peeebeee Sep 06 '18 at 14:08
  • 1
    Have you tried this outside of the do/while loop? You're creating an ajax call every loop iteration, so hundreds, even thousands of pending ajax events will be queued before the first response even arrives back, which might crash the browser or at least spam the javascript function queue so full that your success callback is buried under all those calls. If you need to loop until you get a response, at least have the succes/error function trigger the next iteration instead of doing this is a loop. – Shilly Sep 06 '18 at 14:11
  • Log an error to the console inside the error function to see if your code reaches it. – Adam Sep 06 '18 at 14:12
  • @Shilly The first response is never handled when it arrives, since JS is still busy with the `do..while` loop. – Teemu Sep 06 '18 at 14:19

1 Answers1

0

You will in an infinite loop and you browser will crash and you will never get a error message, success, etc!

Please try without do while:

var response=jQuery.ajax({
    url : "https://127.0.0.1:18647/dcs/dcs_6200808/",
    method : "POST",
    //data : formData,
    //cache : false,
    //async : false,
    success : function(data, textStatus, jqXHR){
        //debugger;
        console.log("hey i am up");
        isServiceUp=true;
        },
    error : function(jqXHR, textStatus, errorThrown){

    }
});

Please look at this: JavaScript Infinite Loop?

Serkan Sipahi
  • 691
  • 6
  • 19