I have a success function in my AJAX that returns the response text from a python script, which can be either “SUCCESS” or “EMPTY”. Now I want to place the if-loop inside the success function, but the if-loop does not work. I get the correct data from my python script because my warning statement works fine and prints "SUCCESS". But he is not included in ifloop
I tried a bunch of things, but the control is not included in the if-loop, can someone tell me what I'm doing wrong:
submitHandler: function (form) { $.ajax({ type: 'post', url: '/cgi-bin/getdataworld.py', data: $(form).serialize(), success: function(data) { //document.write(result); console.log("result is "+data); alert(data); if(data === "SUCCESS"){ window.location = 'index.html'; } else{ alert("NO DATA PRESENT"); } }, error: function (responseData) { console.log('Ajax request not recieved!'); } }); return false; }
source share