我正在尝试获取我的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); },
以上就是jQuery教程分享无法获取所有POST Success xml数据相关内容,想了解更多jQuery开发(异常处理)及jQuery教程关注计算机技术网(www.ctvol.com)!)。
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/jquerytutorial/557826.html