I've been encountering an issue while trying to set the XHR responseType to "json". Everything seems to be working fine when I keep it as an empty string xml.responseType = "";
. However, once I switch it to "json", I'm hit with the console error message SYNTAX_ERR: DOM Exception 12.
Here's my .js file:
var xml = new XMLHttpRequest();
xml.open("GET", "test.php", true);
xml.responseType = "json";
xml.send();
And here's the corresponding .php file:
<?php
$foo = "{\"key1\":\"val1\", \"key2\":\"val2\"}";
echo $foo;
?>
I'm stumped on this one.. Any suggestions or insights would be greatly appreciated!