Skip to content Skip to sidebar Skip to footer

Ajax Php Conditional Logic Not Evaluating Correctly

For some reason my ajax.responseTest coming from my PHP will not evaluate correctly in the javascript conditional code I have below. The ajax.responseTest is coming back as 'signup

Solution 1:

Assuming that the reference PHP code is posted correctly, you have has leading whitespace in your script:

<?php
^^^^

And the output would be:

    signup_success

Try removing unnecessary whitespace from your script or trim the responseText:

if(ajax.responseText.replace(/^\s+|\s+$/g, "") == "signup_success") ...

Post a Comment for "Ajax Php Conditional Logic Not Evaluating Correctly"