Search code examples
javascriptcomparatorequality-operator

String equality( == ) issue in javascript


I am getting undesired output when i compare the ajax response to a string.
My backend is PHP. It is an echo 'SUCCESS' that responds to the ajax call.
When i compare the response with "SUCCESS" it is giving a false output!

Let me attach a screenshot of the console watch window for clarity.

Console screenshot

Please help me with a workaround. Thank you!


Solution

  • I guess there is a space in the success written at the top (pinkish) one. Remove that. For checking give a space in the if condition. If it succeeds then that is the issue.