Cross Domain XmlHttpRequests (http://benreichelt.net/blog/2005/4/11/Cross-Domain-XmlHttpRequests-Ajax/)
2008-06-17 21:08
633 查看
Cross Domain XmlHttpRequests (Ajax)
11 Apr, 2005Uncategorized
One problem you run into when using client side xml calls is the
issue of getting some xml from a different domain. Making a
cross domain request is simply denied in Firefox, and I believe it is
denied in SP2 IE, however pre-SP2 you were just alerted to the fact
that a cross domain request was being made. On some of our pages
we want to include Yahoo news feeds that
relate to the content on the page. Since we couldn�t just make
the request (Response.Redirects also do not work), I wrote a little
page that takes in another url as a querystring parameter, makes its
own web request to that page, and streams the content down to the
client. This allows you to get any feed from any domain you want,
so it can come in pretty handy for the scenario I described
above. Here is the code from the intermediate page:
UPDATE:
Sorry for the poor formatting, I guess I’m not using CopySourceAsHTML
in the correct way. If you view the post on my blog page, the
formatting is intact.
8
9 namespace MyApp.Web.Services
You�ll notice in the �GetExternalFeed� method, I�m UrlDecoding the
querystring parameter to create a valid url from the string. Make
sure to use the javascript �escape�
function on your querystring parameter before making the request,
otherwise any �&� in the url will be lost and your url will be
invalid.
So thats all there is to it, now you can get xml feeds from anywhere on the web!
相关文章推荐
- Cross Domain XmlHttpRequests (http://benreichelt.net/blog/2005/4/11/Cross-Domain-XmlHttpRequests-Ajax/)
- Ajax之一: XMLHttpRequest (应用环境: Windows + IE + .NET[C#])
- XMLHttpRequest cannot load file. Cross origin requests are only supported for HTTP angularjs
- 新瓶旧酒ASP.NET AJAX(8) - 客户端脚本编程(Sys.Net命名空间下的WebRequestManager、WebRequest、WebRequestExecutor和XMLHttpExecutor)
- http://www.blogjava.net/zyl/archive/2006/12/29/90802.html maven 配置篇 之 settings.xml
- 完成 ajax.net 的cross domain ajax功能实现
- CSSHttpRequest : cross domain ajax request for easy
- ambari,hadoop本地源 部署http://blog.chinaunix.net/xmlrpc.php?r=blog/article&uid=26230811&id=4023821
- Ajax之二: XMLHttpRequest之POST传递XML (应用环境: Windows + IE + .NET[C#])
- 系统地学习ASP.NET AJAX(8) - 客户端脚本编程(Sys.Net命名空间下的WebRequestManager、WebRequest、WebRequestExecutor和XMLHttpExecutor)
- 使用XStream注解实现Java对象与XML互相转换的代码示例---转自:http://www.blogjava.net/bolo
- 关于Chrome浏览器使用ajax访问本地文件报 Cross origin requests are only supported for HTTP
- ASP.NET MVC中使用AJAX(XMLHttpRequest、Microsoft AJAX Library......)
- ASP.NET MVC中使用AJAX(XMLHttpRequest、Microsoft AJAX Library......) 推荐
- js:浏览器跨域ajax变通实现 -- flash + js + crossdomain.xml
- 系统地学习ASP.NET AJAX(8) - 客户端脚本编程(Sys.Net命名空间下的WebRequestManager、WebRequest、WebRequestExecutor和XMLHttpExecutor)
- http://blog.csdn.net/hxcfindjob(AJAX学习)
- 跨域文件crossdomain.xml在weblogic上的部署和http://10.165.26.151:7001/xx.xml可以访问一个文件
- NET中用JavaScript来创建XMLHttpRequest 的Ajax开发介绍
- Ajax本地跨域问题 Cross origin requests are only supported for HTTP