I am writing code that will use AJAX requests to get some HTML code from the server to embed, but I cannot seem to get the JSON format correct. Can anyone tell me what I am doing wrong?
{"response":
[
{"code": "<div id=\”sponsors\” class=\”infoBox\” > <div class=\”title\”>THANK YOU 2011 SPONSORS!</div> <div class=\”section\”> <div class=\”party\”><a href=\”http://www.ChickRussell.com\”>Chick Russell Communications</a></div> <div class=\”cityState\”>Pasadena, California</div> <div class=\”description\”> Chick Russell Communications is a story-driven creative development company, not a design-driven company. It's one of our main distinguishing features. It doesn't matter how great it looks if it doesn't create the desired effect. <a href=\”/vendors/info/17280\”>more...</a> </div> <div class=\”web\”><a href=\”http://www.ChickRussell.com\”>www.ChickRussell.com</a></div> </div> </div>"
}
]
}
When I try to run JSON.parse()
on it, I get a syntax error
Here is the code I am using to read the JSON:
<script language="JavaScript" type="text/javascript">
var newxhr = new XMLHttpRequest()
newxhr.onreadystatechange = getResponse
function getResponse(){
if(newxhr.readyState == 4) {
var response = newxhr.responseText;
console.log(response)
response = JSON.parse(response)
newxhr.close;
}
}
var url = "http://*.*.net/test.json";
newxhr.open("GET", url, true);
newxhr.send(null)
</script>