Im seeing some very odd stuff in a simple ajax/jquery code I wrote and I can't explain why Im seeing what Im seeing.
I have a php file called complete.php, the only thing this does at the moment is:
echo "saved"; I have a jquery ajax call, which has a .done() function, which looks like this:
jQuery.ajax({ type: "POST", url: "complete.php", data: "id=someIdHere", }).done(function(d){ alert(d); if(d == "saved"){ alert('loading done'); }else{ alert('error'); } }); My firebug confirms the response from the complete.php is 'saved'.
when I typeof the 'd' response, it is of type 'string',
however for some reason, the alert I get in the .done() function, is 'error' and not 'loading done'.
the 'alert(d)' just before the if statement gives 'saved'.
What am I missing here?
typeof dsucessfully as "string", have you tried loggingditself? What is it?.done()function and check the value ofd. There might be more than just what you hope.d:if($.trim(d) == "saved")