Front-end and back-end transfer problems
Today, when I was doing an ajax to verify the existence of the user name, an unexpected problem occurred. It may be caused by the fact that I haven't reviewed the front-end knowledge for a long time, so let's not talk about the problem directly.
My back-end receives the request: Then and The code for processing and then returning the value: The code for
processing the return value at the front end: The
result is: whether I enter the user name in the database or not, the user name is available, and the next else statement block will not be executed at all. Code, which makes me wonder.
The problem: It seems that the console output is not wrong. In fact, data is a string and cannot be used directly as a boolean value. All the following operations are required. At the time, I was also confused and wanted to steal a little lazy.
This was successfully solved. The problem is, the effect after successfully solved, can completely achieve the effect I want.