Today, when making a new requirement, use jquery's Ajax to return a query result:
But when this method is called, the data has the information, the call of the place obtained is always undefined, in the online search for some information, found the problem, the solution is as follows:
1: The attribute needs to increase async:false;
2: Declare a variable before Ajax, in success, assign data to the variable, and after Ajax, return the variable;
Because if it is asynchronous execution, perhaps the query results have not returned, JS this way to return the data back, but only add the Async:false attribute but does not solve the problem;
Return to data directly, it will still be undefined, why this place to use a variable to accept the data, and then return the variable, I do not know why;
First of all hope that this place can help everyone, but also hope that the 2nd more understanding of the friends can answer my questions;
The return statement in jquery Ajax cannot return a value