客户端jquery中没有webserver的xml? [英] xml in jquery in client side without webserver?

查看:60
本文介绍了客户端jquery中没有webserver的xml?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的html文件中使用以下代码并通过双击仅手动运行而不是在webserver中运行。它没有解析xml并给出正确的节点值?有什么帮助吗?如果xml内容很大,jquery
将如何工作,因为我使用的代码没有回调函数,它如何识别解析前收到的所有xml数据?

I am using following code in my html file and run manually not in webserver through double clicking only.it did not parse xml and give correct node value? any help please? how jquery will work if xml content is big one, because the code i have used is not having callback function, how does it identify all xml data has been recieved before parsing?

 <script type="text/javascript" src="jquery.js"></script>
 <script type="text/javascript">
 $(document).ready(function(){
 $.get("http://www.hindu.com/rss/01hdline.xml", function(response){
 var response = $.paseXML(response);
  var $xml = $(response);

 //Now you can find any xml node with $xml using various methods of jQuery
 //E.g
  alert($xml.find( "title" ));   
 });
 });


推荐答案

您的成功处理程序将不会被调用,发出警报因为 Same Origion Policy 而在firebug中看到。另请参阅跨源资源共享

your success handler will not be called, place an alert of see in firebug, because of "Same Origion Policy". Also have a look at Cross-Origin Resource Sharing

你可以做的是做一个服务器端代理,向Url发出请求并得到一个xml响应,然后将该响应传回给你的客户端,在那里你可以使用jquery来解析xml。

what you can do is make a server side proxy, make request to the Url and get a xml response, then pass back that response to your client side where you can use jquery to parse the xml.

这篇关于客户端jquery中没有webserver的xml?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆