I am trying to create/change a javascript array based on what is return from an ajax call. This is what I am working with so far:
function ajaxCall(code) {
xmlhttp=new XMLHttpRequest();
xmlhttp.open("POST","ShowBusiness",false);
xmlhttp.send(code);
document.getElementById("content").innerHTML = xmlhttp.responseText;
}
and then within that response HTML I have (among other elements)
<script type="text/javascript">
images = [1, 2, 3];
</script>
However, when I then try to use console.log(images);
within a function that was in the original page, it tells me that "images is not defined". I then tried to go back and insert a var images = [];
into the head of the original page, but then the console log returns [], not what I hope to change as a result of the ajax call.
Any ideas how I can get around this? I assume that the page is not recognizing the javascript that I am inserting into the page with ajax.