Reputation: 1
if you copy http://tgbs.ir/xml/Category.xml in your browser , you will see content of xml file. but in below code alert doesnt show and i think url doesnt work . please help me to solve this problem because this code has to read from this url.
Date.ReadCategoryXml = function() {
var counter=0;
$.ajax({
type: "GET",
url: "http://tgbs.ir/xml/Category.xml",
dataType: "xml",
success: function(xml) {
$(xml).find("category").each(function() {
var cTitle = $(this).find("title").text()
var cUrl = $(this).find("url").text();
Data.arrCategory[counter++]= new Category(cTitle,cUrl);
});
alert("behnaz");
}
});
}
Upvotes: 0
Views: 3126
Reputation: 52779
You can try using jsonp to get cross domain calls More info @ http://api.jquery.com/jQuery.ajax/
Example
$.ajax({
url: 'http://tgbs.ir/xml/Category.xml',
dataType: 'jsonp',
success: function( data ) {
alert("Success : "+data);
}
});
Upvotes: 2
Reputation: 14205
http://tgbs.ir the Domain where the script runs? If not… You can't load xml data from an other Domain because of the Same origin policy
Possible Solution: craigslist rss feed
In short... you have to build a wrapper function which gets your data.
Upvotes: 1