无法获取所有POST Success xml数据

我正在尝试获取我的xml标记结果并将它们加载到地图上,但是当我发出警报时,我在变量中得到的结果是:

数据加载:[对象XMLDocument]

这就是我的代码:

function SendData() { //get data from inputs $.ajax({ type: "POST", url: "MapSearchxml.php", data: { dataFromDate: FromDate, //some more data dataHasPatio: HasPatio }, beforeSend: function (html) { // this happens before actual call }, success: function (html) { // this happens after we get results alert("Data Loaded: " + html); } }); } 

在Firebug中,post回复如下:

我尝试将数据类型设置为xml,如下所示:

  success: function (html) { // this happens after we get results alert("Data Loaded: " + html); }, dataType: 'xml' }); } 

但是没有发生变化。

这是我的xml php代码:

 $result = mysql_query($query); if (!$result) { die('Invalid query: ' . mysql_error()); } header("Content-type: text/xml"); echo ''; while ($row = @mysql_fetch_assoc($result)){ echo ''; } echo ''; 

这是浏览器在将XML对象附加到文本字符串并在警报中显示数据时处理XML对象的方式。 你的ajax调用看起来像是在工作。

您可以尝试更改:

  success: function (html) { // this happens after we get results alert("Data Loaded: " + html); }, 

只是:

  success: function (html) { // this happens after we get results console.log(html); }, 

并在JavaScript控制台中查看该对象。 要么:

  success: function (html) { // this happens after we get results var xmlString = (new XMLSerializer()).serializeToString(html); alert("Data loaded: " + xmlString); },