I have an external PHP script that could echo an error, data, or different success messages from the same function call. These are echoed to a JS file which can display the data anywhere on an HTMl page. Is this the best way to do it?:
- Using "json_encode", create JSON with a status code key-value pair and a message/data key-value pair.'
- Echo back the JSON.
- Back in the JS file, retrieve the JSON and store it as a variable.
- Put it through an if or switch statement, where the I could use the status code value to determine where to d.gEBI() place the message value (or whatever I want to do with the data).
This is the only way I know that could work with this setup (an external php script called from either external JS file or inline JS in HTML page).