jquery.ajax() not working
I am trying to fetch xml file using jquery.post() method. My code is :
function getTitle()
{
jQuery.ajax({
type: "POST",
url: "https://spreadsheets.google.com/feeds/spreadsheets/private/full.txt",
dataType: "xml",
success: function(xml) {
var i=0;
$(xml).find('entry').each(function(){
开发者_StackOverflow社区 if($(this).find('title').text().toString() == "Sample Spreadsheet"){
var href = $(this).find('link')[1].getAttribute('href').toString();
var url="https://spreadsheets.google.com/feeds/worksheets/" + href.split('=')[1] + "/private/full";
alert(href.split('=')[1]);
}
i++;
});
}
});
}
But, it is not giving me alert ! How do I solve ?
The AJAX same origin policy
does not allow a request like this. Only way to request data from another domain is to use JSON-Padding.
http://en.wikipedia.org/wiki/Same_origin_policy
My first suggestion is that you download a tool that allows you to view http data. A good free tool for this is Fiddler. It will vastly improve your ability to debug this type of problem.
精彩评论