开发者

jQuery XML Parsing Not Working Locally in Safari 4.0.4

I'm new to this site, but it seems like someone out开发者_开发百科 there should be able to answer my question.

I've recently started using jQuery, and spent the day slamming my head against the desk trying to successfully parse an XML file and append the text to a div. After failing at this in Safari, I switched over to Firefox, and found it working perfectly! Furthermore, when I loaded the files to my server and loaded the same page in Safari, it works fine there too! It seems that Safari is having trouble parsing from a local XML file. Has anyone experienced this, and have any explanation or solution? Here's my code:

$(document).ready(function(){
  $.get('datafile.xml',{},function(data){
    $(data).find('item').each(function(){
      var dataHolder = ($(this).find('title').text());
      $('#textBox').append(dataHolder + "<br />");
    }); 
  }); 
});

Again, this works perfectly both locally and remotely in Firefox and also works in Safari remotely. Locally, Safari doesn't work.

If anyone wants to see the HTML file as well, let me know. It's pretty straightforward. Just a div with an id of textBox. The XML file is as well. Just a list of items and titles.

Thanks a million in advance to anyone who can help me out with this!


What response are you getting from the server when you make your GET request? If you use $.ajax and specify an error handler, is the error handler getting called? It seems like you might be hitting XSS protection somehow, but I don't see how local > local would fail.

If this is the issue, then there is no workaround aside from running Apache/web container locally and serving the xml file and html file with javascript both from the web container.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜