问题描述
我已经开始从事私人项目了。但是,在第一阶段已经遇到了问题。
返回的数据是XML格式(不是很糟糕,但需要花费很多精力来解析可用对象)
远程服务器除了自己以外不接受任何ORIGIN,因此浏览器抛出错误:Access-Control-Allow-Origin不允许原点*。
(*)可以是null,localhost或我的网站。
所以我一直在搜索,但无法找到任何结果。
当使用$ .ajax时,似乎没有替代jsonp参数,并且名称$ .getJSON正如它所说的那样,检索JSON,而不是XML。
所以我想知道,还有其他替代方法来检索外部XML数据,同时在发送请求时禁用ORIGIN属性吗?
你的Sincerley,Lars
----
我注意到有可能获得PHP的内容unction:file_get_contents。但是我真的想知道使用JQuery是否有不同的方式。
如果有人知道如何让JQuery与返回的PHP文件内容进行通信,请随意给我看:'']
I''ve started to work on a private project. However, in the first stage already faced a problem.
The returned data is in XML format (not that bad, but takes alot of effort to parse to usable objects)
The remote server doesn''t accept any ORIGIN except for himself, so the browser throws the error: Origin * is not allowed by Access-Control-Allow-Origin.
the (*) could either be null, localhost, or my website.
So I have been searching, but unable to find any results.
It appears there is no alternative for the jsonp argument when using $.ajax, and the name $.getJSON is as it says, ment to retrieve JSON, not XML.
So i''m wondering, it there any other alternative method to retrieve the external XML data while disabling the ORIGIN property when sending the request?
Yours Sincerley, Lars
----
I''ve noticed it is possible to obtain the contents with the PHP function: file_get_contents. But I''d really like to know if there is a different way using JQuery.
And if anyone knows how I could let JQuery communicate with the returned PHP file contents, please feel free to enlight me :'']
推荐答案
这篇关于$ .getJSON或$ .ajax替代XML检索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!