Outstanding issues with jQuery.ajax() in IE8?
I am loading feed-items into a ul using this jQuery .ajax() call, which I basically lifted from http://www.makemineatriple.com/2007/10/bbcnewsticker/
var timestamp = true; //set whether timestamp is displayed in
$.ajax({
type: "GET",
url: "sample-feed.xml",
dataType: "xml",
success: function(xml) {
$(xml).find('item').each(function(){
var title = $(this).find('title').text();
var link = $(this).find('link').text();
if(title.length >=57){
title = title.substring(0,54) + "...";
}
var addItem = '<li class="tickerTitle"><a href="'+link+'">'+title+'</a>';
if (Boolean(timestamp)== true){
var time = new Date(Date.parse($(this).find('pubDate').text()));
addItem +='<span class="timestamp">' + makestamp(time) +'</span></li>';
}
$('ul#news').append(addItem);
});开发者_开发技巧
It works in Chrome 4 and Firefox 3.6, but I load it up in IE8 and somehow the ajax call fails. I have tried to use IE8's Developer tools to see where exactly it fails, but I haven't been successful yet.
So two questions
- Is there anything blatantly wrong with my ajax call here that could be preventing me from seeing it in IE where it works in FF/Chrome?
- Are there any special considerations I have to make for the Internet Explorer family of browsers with regards to this particular jQuery method?
I've done some googling on this but nothing obvious is coming up.
One other note: I am currently using jQuery 1.3.2 due to some legacy scripts on the same site. I did try loading 1.4.2 and it had the same results on IE8
Are you doing your tests in local file system? Then you most probably get "Access denied", since each file is counted as a different origin and "same-origin-policy" is applied by IE.
If it is on the server already, I suggest you watch HTTP traffic between your computer and the server, using Fiddler Tool (http://fiddlertool.com) to see if the ajax call is actually issued.
I know this is old but apart from that Access Denied issue, there was a couple missing curly braces and a paren in the code example above:
} //ends success function
}); // ends ajax object and method
精彩评论