So i have a simple task, get an xml feed from a server that is not ours. easy enough, however im running into allow origin control issues and the &callback= tag isnt solving the issue.
$.get("http://www.buytopia.ca/feed",data,jloop(),"xml");
function jloop(){
var count=0;
//dummy code
document.write("please work");
do{
document.write(count);
count++;
}
while (count<10);
};
so when i run this, the get call is pending, not retieving. ive tried different feeds, like NASA but adding the &callback= doesnt remove access origin problems. All i need is a working chunk of code to get the feed, preferably to that buytopia.ca feed because we have access to it and know its permission info. Then i can begin to parse it. Any help would be great! thanks!
Is buytopia your domain. You cant make ajax calls accross domains. Its called cross site scripting.
You can do an ajax call to a local php file (let's say you call it currency.php), and get it through php as in, for example (the php is from ECB's web site, for developers - the ajax is mine)
$XML=simplexml_load_file("http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml");
//the file is updated daily between 2.15 p.m. and 3.00 p.m. CET
foreach($XML->Cube->Cube->Cube as $rate){
//Output the value of 1EUR for a currency code
echo '1€='.$rate["rate"].' '.$rate["currency"].'<br/>';
if ($rate["currency"]=='USD') {
echo 'EUR-> USD RATE: '.$rate["rate"], '<br/>';
}
//--------------------------------------------------
//Here you can add your code for inserting
//$rate["rate"] and $rate["currency"] into your database
//--------------------------------------------------
}
Then the ajax call would be something like:
<script>
$.ajax({
url: 'currency.php',
type: 'POST',
data: {myCurrency: curr,
myPriceAmt: amount },
success: function(data){
// do any manipulations here
}
});
</script>
Good luck!