I have an HTML page which calls a PHP page ( DB called here) via Ajax then back to my HTML page.
I have tried echo and print and of course they will not work for this rookie.
What is a workable syntax please.
Thanks
I have an HTML page which calls a PHP page ( DB called here) via Ajax then back to my HTML page.
I have tried echo and print and of course they will not work for this rookie.
What is a workable syntax please.
Thanks
Try to respond (in php) with json. So do something like this:
[php]header(‘Content-type: application/json’);
// some code
echo json_encode(array(‘error’ => ‘your error here’);[/php]
If you use jquery then it should detect the response automatically. If it doesn’t then try forcing datatype: json, and set the content type in php to json (as I did in the example)
Then you should have a javascript object in the success function. so you should be able to use result.error in javascript.