views:

110

answers:

1

This is strange. I am used to IE crapping out on problems with XML format, but this is the first time I have had a problem in Firefox.

The XML is created at this page:

http://www.harrahs.com/content/events/EventCalendarFeedXml.jsp?propCode=UHA&uniqueEvents=y&showTimes=y

The code I am using to pull in the XML is

    //Read XML for Events
$.ajax({
    type: "GET",
    url: "/content/events/EventCalendarFeedXml.jsp?propCode=UHA&uniqueEvents=y&showTimes=y",
    dataType: ($.browser.msie) ? "text" : "xml",
    success: function(data) {
        var xml;
        if (typeof data == "string") {
            xml = new ActiveXObject("Microsoft.XMLDOM");
            xml.async = false;
            xml.loadXML(data);
        } else {
            xml = data;
        }
        var eventNumber = 0;
        $('event', xml).each(function(i) {
            if ($(this).find("venue").text() == "The Venue") {
                eventNumber += 1;
                //Limit results to 3
                if (eventNumber < 4) {
                    $("#event" + eventNumber + "href").text($(this).find("eventTitle").text());
                    $("#event" + eventNumber + "dateTime").text($(this).find("description").text());
                    $("#event" + eventNumber + "href").attr({
                        href: $(this).find("eventDetailsPageUrl").text()
                    });
                }
            }
        });
        if (eventNumber == 2) {
            $("#event3").hide("slow");
        }
        if (eventNumber == 1) {
            $("#event2").hide("slow");
            $("#event3").hide("slow");
        }
    },
    error: function(XMLHttpRequest, textStatus, errorThrown) {
        alert("Error: XMLHttpRequest: " + XMLHttpRequest + ", textStatus: " + textStatus + ", errorThrown: " + errorThrown);
        // typically only one of textStatus or errorThrown 
        // will have info
        this; // the options for this ajax request
    }
});

I am getting a parsererror, and I can't figure out why. Any help?

+1  A: 

The server sends Content-Type: text/html which is not correct. It has to be text/xml. Just change your server side script to return the correct mime type and it will work.

Darin Dimitrov
Thanks, quick and accurate answer.
mrr0ng