1

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");

    }
});

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.

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

2 Answers 2

2

Try to add an Error function as well.

See enter link description here

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
    }
});
Sign up to request clarification or add additional context in comments.

Comments

1

you need to parse it first, and then you can search for the attributes. like this.

success: function(data) {
        var xml = $.parseXML(data)
        $(xml).find('StopLocation').each(function()
    {
        var name = $(this).attr('name');
        alert(name);
    }       
    );

this will give you the name of each StopLocation.

hope this helps, you can use the same method for all other attributes in the document also.

1 Comment

This seems to work in DreamWeaver. I get the attributes in an alert. But still doesn't work in neither Firefox or Chrome.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.