The source of the issue is the setting of the innerHTML, there seems to be a size-limit in Chrome, see innerHTML size limit
The result is invalid js-code.
Solution:
This line:
eval(document.getElementById("mapgen").innerHTML);
will not have the desired effect. The Request runs asynchronously, at the moment when this line will be executed the response isn't available yet, the innerHTML of #mapgen is empty, nothing will be done.
Basically you don't need to use eval
at all, because the script will be executed automatically when you set the innerHTML.
But when you can't set the innerHTML because of the size eval()
the responseText
directly(in the onreadystate
-callback):
window.onload = function()
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
eval(xmlhttp.responseText);
}
}
xmlhttp.open("GET","the/desired/url",true);
xmlhttp.send();
}
However, the current approach to load the markers isn't recommendable.
You send a form, load a new page and send another request to load a large script which must be evaluated.
You better send the form via AJAX to load the markers, and instead of returning a script return a JSON with the marker-properties only(the creation of the markers may be done in a loop where you parse the returned JSON)