On Nov 12, 2007, at 6:57 AM, [EMAIL PROTECTED] wrote:

hi folks.

ok. it's possible to make cross-domain ajax calls if you get json
data, but i need to to pull xml.

i need to get some xml data from another domain.
isn't there any solution for this problem? :(



I use curl with PHP to create a mirror xml file on my own domain. Then I just reference that in the $.ajax()

I'm sure there are similar ways to do this with other languages, too. Here is an example:


<?php
header('Content-Type: text/xml');
$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, 'http://feeds.feedburner.com/jquery/');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);

// display file

echo $file_contents;
?>

Also, PHP offers a simpler way to do this using file_get_contents, but my web host (Dreamhost) doesn't allow it:

<?php echo file_get_contents("http://feeds.feedburner.com/jquery/";); ?>

Hope that helps.

--Karl
_________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com




Reply via email to