Well, the ajax call reads the response from the server, and that response must be rendered as some type of readable data, such as application/json
or text/html
.
In order to write that data, you need to echo
it from the server with PHP.
The return statement doesn't write data, it simply returns at the server level.