Those pits on the front and back ends? Have you stepped on it?

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
Insert picture description hereprocessing the return value at the front end: The
Insert picture description hereresult 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.

Insert picture description here
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.
Insert picture description here
This was successfully solved. The problem is, the effect after successfully solved, can completely achieve the effect I want.
Insert picture description here

Guess you like

Origin blog.csdn.net/m0_46188681/article/details/112794050