views:

355

answers:

5

i've got a foo.php file which retrieves client infomation and generates an xml output with the relevant client info.

i'm trying this ajax call which does not seem to want to work

$.get('http://www.foo.php','',function(xml){ $('samplenode',xml).each(function(i){ //stuff done here }); }, 'xml');

i'm still new to javascript, jquery and ajax, so there might be something really silly that i'm overlooking.

(i've tried replacing foo.php with a foo.xml file with a copy/paste of a sample output, and that works fine, so it really seems to be a problem with the call to a php file. and if i go straight to the foo.php file with my browser, the xml is all there and properly formatted, so the problem does not seem to be the php script itself.)

+2  A: 

Use 'foo.php' instead.

ChaosPandion
+1  A: 

is your get url correct? You have:

'http://www.foo.php'

Should that be:

'http//www.mysite.com/foo.php'
Eric Petroelje
A: 

do you set content-type properly?

rezna
A: 

actually, turns out it was a problem with the 'type' argument of the $.get function.

simply omitting it seems to have solved the problem

zaphod
A: 

If you want to leave the type, send you document with the correct content type by starting the php with:

header ("content-type: text/xml");
Pat