I'm, trying to load som data from an xml file using jQuery and ajax but i don't anything back from the ajax request.
The xml
<?xml version="1.0" encoding="utf-8" ?>
<items>
<item key="NewSite">Create new site</item>
<item key="EditSite">Edit site</item>
<item key="DeleteSite">Delete site</item>
<item key="ViewSite">View site</item>
<item key="ViewSiteList">View full site list</item>
</items>
The jQuery
var createsite = "";
//--- get trasnlated text for the notify box
$.ajax({
url: "/Areas/Admin/Content/Scripts/admin/da-DK.xml",
method: "GET",
dataType: "xml",
success: function (xml) {
var xmlDoc = $.parseXML(xml),
$xml = $(xmlDoc);
$xml.find('item').each(function () {
createsite = $(this).attr("CreateSite").text();
});
console.log(createsite);
}
});
But the console log is empty. What am I missing here ?
/Martin
errorhandler.parseXML(which expects a string)?dataTypeit'll turn returned data as that specific type so you don't need to parse it. If you still have problem, take a look atxmlto check whether it's been filled or not.