Stigma
Stigma

Reputation: 272

jQuery - Ajax request for xml file not showing errors yet I can't fetch its contents

I have two files in the same directory, fetch.html & other.xml (so this doesn't appear to be a CORS issue.) - there are no errors in the console and the network tab shows that I have sucessfully retrieved the xml file.

I try selecting an element from other.xml ($("restaurant")) in the console and it returns an empty array without any errors. I've cleared cache and renamed the files but nothing is changing. Does anyone have an idea of why this is happening?

At the bottom of the body in fetch.html I have this script:

<script>
$(function(){
    $.ajax({
        url: "other.xml",
        success: function(data) {
            console.log("Success");
        }
    });
});
</script>

other.xml looks like:

<?xml version="1.0"?>
<restaurants>
    <restaurant name="Pan Africa Market" address="1521 1st Ave, Seattle, WA" lat="47.608940" lng="-122.340141" type="sitdown"/>
    <restaurant name="Buddha Thai &nbsp; Bar" address="2222 2nd Ave, Seattle, WA" lat="47.613590" lng="-122.344391" type="bar"/>
    <restaurant name="The Melting Pot" address="14 Mercer St, Seattle, WA" lat="47.624561" lng="-122.356445" type="sitdown"/>
    <restaurant name="Ipanema Grill" address="1225 1st Ave, Seattle, WA" lat="47.606365" lng="-122.337654" type="sitdown"/>
    <restaurant name="Sake House" address="2230 1st Ave, Seattle, WA" lat="47.612823" lng="-122.345673" type="bar"/>
    <restaurant name="Crab Pot" address="1301 Alaskan Way, Seattle, WA" lat="47.605961" lng="-122.340363" type="sitdown"/>
    <restaurant name="Mama's Mexican Kitchen" address="2234 2nd Ave, Seattle, WA" lat="47.613976" lng="-122.345467" type="bar"/>
    <restaurant name="Wingdome" address="1416 E Olive Way, Seattle, WA" lat="47.617214" lng="-122.326584" type="bar"/>
    <restaurant name="Piroshky Piroshky" address="1908 Pike pl, Seattle, WA" lat="47.610126" lng="-122.342834" type="sitdown"/>
</restaurants>

Upvotes: 0

Views: 68

Answers (1)

a better oliver
a better oliver

Reputation: 26828

<restaurant name="Buddha Thai &nbsp; <---

&nbsp; is not a predefined entity in XML. You can't use it in a plain XML document. If need &nbsp; in your app then you can escape it as &amp;nbsp;

Upvotes: 1

Related Questions