Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

outputting data as XML, and loading with jquery ajax


Reply


4 Posts   1194 Views

Avatar
Futureweb

Community Member, 233 Posts

15 August 2011 at 9:44am

Hi all,

I've currently a whole load of data i'm outputting to a template, which constructs it in a XML format.

when the page is loaded, i'm to load the file I'm using

jQuery.ajax({
url: urlToLoad,   
success: function(xml) { }
});

However, I'm having a load of problems!

Firstly, in IE, I have to write $.ajax - and in firefox I have to put jQuery.ajax

of course, i need one line to do both!

2ndly, when file is loaded, I'm trying to load the data using:

jQuery(xml).find('marker').each(function(){

this works fine in firefox, but not IE

So, I either fix the above, or I'm just wondering if there is another, different way of using jquery to load data in...

Thanks all

Avatar
Futureweb

Community Member, 233 Posts

15 August 2011 at 10:01am

Ok, I've crudely sovled the first bit adding

var myJQueryOb = $;

and then using

myJQueryOb.ajax({ });

and this works in IE and Firefox

I think the XML is to do with the fact i'm just using a SS template which looks like XML, but isn't an xml file:
http://stackoverflow.com/questions/562283/jquery-find-doesnt-return-data-in-ie-but-does-in-firefox-and-chrome

Avatar
MarcusDalgren

Community Member, 288 Posts

15 August 2011 at 10:23am

You need to set the headers properly by putting the code below in the controller method that outputs the xml.
Check in firebug to make sure that the proper header is being set.

$this->getResponse()->addHeader("Content-Type", "text/xml");

Avatar
Futureweb

Community Member, 233 Posts

15 August 2011 at 11:02am

all works now...
even in ie6!