jQuery-解析从URL接收的XML [英] Jquery - parse XML received from URL

查看:84
本文介绍了jQuery-解析从URL接收的XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个URL,据称我应该从中接收XML.到目前为止,我有这个:

I have this URL, that I supposedly should receive an XML from. So far I have this:

    function GetLocationList(searchString)
    {

  $.ajax({
    url: "http://konkurrence.rejseplanen.dk/bin/rest.exe/location?input=" + searchString,
    type: "GET",
    dataType: "html",
    success: function(data) {

    //Use received data here.
    alert("test");

    }
});

尝试使用Firebug进行调试,但未纳入成功方法. 但是,在DreamWeaver中,它能够发布简单的警报,该警报位于成功方法的内部. 我尝试将 xml 编写为dataType,但是当我编写alert(data)时,它不起作用(在DreamWeaver中). 但是,当我将 html 编写为dataType时,它会显示整个XML的警报.

Tried to debug with firebug, but it doesn't go into the success method. Though, in DreamWeaver it is able to post a simple alert, which is inside the success method. I tried writing xml as dataType, but it doesn't work (in DreamWeaver) when I write alert(data). But it shows an alert with the entire XML, when I write html as dataType.

如何正确获取XML?如何解析(例如)获取"StopLocation"元素?

How do I get the XML correctly, and how do I parse and for example get the "StopLocation" element?

推荐答案

尝试也添加一个Error函数.

Try to add an Error function as well.

请参见在此处输入链接描述

这将为您提供使用Firefox调试代码所需的所有信息.

This will give you all the informations you need to debug your code with Firefox.

$.ajax({
    url: "http://konkurrence.rejseplanen.dk/bin/rest.exe/location?input=" + searchString,
    type: "GET",
    dataType: "html",
    success: function(data) {

    //Use received data here.
    alert("test");

    },
    error: function(jqXHR, textStatus, errorThrown ){
      // debug here
    }
});

这篇关于jQuery-解析从URL接收的XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆