I am having an XHR call for php script.
Php script returns a JSON object that has the following structure:
`$json_return_data = array(
“ReturnCode” => 0,
“ReturnMessage” => ”,
“ID” => 0,
“XML_Reference_ID” => ”,
“Name” => ”,
“Vendor” => ”,
“Description” => ”,
“Price” => ”,
“Oldprice” => ”,
“Param” => ”,
“Picture” => ”,
“Url” => ”
);
`
As you can see, the first 2 are for detecting the return type and messages.
However, this all falls apart if there is a PHP warning. Because then not only the JSON object gets returned to JavaScript, but the warning does as well.
This makes the `JSON.parse(this.responseText);
What I do in my PHP is:
`$json_file_contents = file_get_contents(“../../../XML-uploaded/variadbles.json”) or
exit(json_encode(`));
`
Is there a way to get rid of these annoying warnings and only keep my JSON?
Thank you,
Andrei