When PHP processes ajax return values, if return, for example, return $ result, fails, echo $ result is okay. The reason is as follows: 1. ajax requests read the return values from the server, and these return values are required
When PHP processes ajax return values, if return, for example, return $ result, fails, echo $ result is okay. The reasons are as follows:
1. ajax requests read the return values from the server, and these return values must be readable data types, such as json or html. To print the returned values, you need echo, but return does not print the data. it simply transmits data on the server.
2. Ajax returns an HTTP request. Return does not generate output (only on the server side), while echo can (from server-> brower, http protocol ). The url of an Ajax request is actually a page that can be displayed in a browser. in php, the return data is only returned on the server side.
To sum up, if the ajax address is a PHP return, the correct data will not be obtained.