Javascript Google Api异步回调失败

Javascript Google Api异步回调失败,javascript,jquery,google-maps,xmlhttprequest,Javascript,Jquery,Google Maps,Xmlhttprequest,我收到了以下内容的请求: function httpGet(theUrl) { var xmlHttp = new XMLHttpRequest(); xmlHttp.open( "GET", theUrl, false ); xmlHttp.send( null ); alert(xmlHttp.status); return xmlHttp.responseText; } 通过以下方式将内容解析到我的新网站后: $Test = httpGet("ww

我收到了以下内容的请求:

function httpGet(theUrl)
{
    var xmlHttp = new XMLHttpRequest();
    xmlHttp.open( "GET", theUrl, false );
    xmlHttp.send( null );
    alert(xmlHttp.status);
    return xmlHttp.responseText;
}
通过以下方式将内容解析到我的新网站后:

$Test = httpGet("www.content.com");
document.getElementById("div_content").innerHTML = document.getElementById("div_content").innerHTML + $Test;
在此之后,我将使用带有回调的google api asynch,但回调函数出现错误

loadScriptFunc('https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true&callback=loadScript');
错误是:window.loadScript不是函数

我已经用jquery$.get完成了,这对我很有用

编辑: 函数的加载方式如下:

if(document.getElementById('map_canvas')){
            loadScriptFunc('https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true&callback=loadScript');
          } 
函数本身看起来像:

function loadScriptFunc(url) 
{
   var head = document.getElementsByTagName('head')[0];
   var script = document.createElement('script');
   script.type = 'text/javascript';
   script.src = url;
   head.appendChild(script);
}   
loadScript函数如下所示:

function loadScript() {
           var head = document.getElementsByTagName('head')[0];
           var script = document.createElement('script');
           script.type = 'text/javascript';
           script.src = 'http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/src/infobox.js';
           head.appendChild(script);
           bLoaded = true;
           window.setTimeout("activateMap()", 100);
         }  
loadScript函数属于my map的模板文件。这段代码已经在Jquerys-$中对我起作用了。获取相同的回调函数等等。但是我不允许使用jquery

编辑2: 我在网上找到了一些东西,我想我知道问题出在哪里了

我已经成功地使用jQuery.load,因为它执行获取的内容中存在的JavaScript代码块和资源。对不起,这个没有演示

我想我不能执行XMLHttpRequest中的代码,有人知道从Url获取内容的另一个js方法吗???

啊,我知道发生了什么。 谷歌地图告诉你它找不到loadScript

所以,你告诉谷歌地图:maps.googleapis.com/maps/api/js?v=3.exp&signed\u in=true&callback=loadScript

看看发生了什么;我让谷歌地图调用initialize

<style>
  #map_canvas {width: 400px; height: 400px;}
</style>
<div id="map_canvas"></div>
<script>
function initialize() {
  var my_position = new google.maps.LatLng(50.5, 4.5);
  var map = new google.maps.Map(document.getElementById('map_canvas'), {
    center: my_position,
    zoom: 7
  });
}
function loadScriptFunc(url) {
  var head = document.getElementsByTagName('head')[0];
  var script = document.createElement('script');
  script.type = 'text/javascript';
  script.src = url;
  head.appendChild(script);
}
if(document.getElementById('map_canvas')) {
  loadScriptFunc('https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true&callback=initialize');
}
</script>

loadScript不是一个函数。jQuery的$.loadScript是一个函数。这是jQuery为您做的事情之一。loadScript是我自己在视图datei中的函数之一。错误报告说该函数不存在。因此,可能您没有在定义loadScript的地方加载脚本。或者可能是以后加载的,所以在需要时它还不存在。你能展示一下这个函数吗,以及你是如何加载的吗?请将函数显式添加到窗口对象!window.callback=function{…}wich-window-Object?我不知道你的代码应该如何帮助我解决我的问题,initiliza对我也不起作用。因此,我的loadScript函数将调用activate Map函数来初始化映射。听着,我告诉你,如果loadScript不存在,你不能告诉Google Maps callback=loadScript。这就是错误报告告诉您的。现在,你的问题是什么?但是loadScript是存在的,这就是我要告诉你的。当我写的时候,同样的方法已经对我起作用了。Google接受自己的函数作为回调函数。请显示一个文档,在那里我可以看到loadScript在哪里。谷歌地图找不到它。这是一个单独的文件吗?它在脚本标签中吗。。。loadScript是一个函数,位于脚本标记中initilize之前10行。这是我地图的模板文件。