改变访问控制 - 允许 - 原产地,让jQuery的load()来工作 [英] changing the Access-Control-Allow-Origin to allow Jquery load() to work

查看:114
本文介绍了改变访问控制 - 允许 - 原产地,让jQuery的load()来工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

状况:

  • 在内部网站上运行过的Web服务器。
  • 的SharePoint逃跑不同的内部Web服务器。
  • 这是所有内部,并且都在同一 company.com 内部域(因为它们是通过 SharePoint.company.com访问不同的子域 internalWeb.company.com
  • Internal web site running off a web server.
  • SharePoint running off a different internal web server.
  • It's all internal, and all on the same company.com internal domain (different sub domains because they are accessed via SharePoint.company.com and internalWeb.company.com)

问题:

  • XMLHtt prequest无法加载 http://SharePoint.company.com。原产地 http://internalWeb.company.com 不受访问控制 - 允许 - 产地允许的。
  • XMLHttpRequest cannot load http://SharePoint.company.com. Origin http://internalWeb.company.com is not allowed by Access-Control-Allow-Origin.

是我想要的:

  • 使用AJAX和JQuery的load()函数从我的网站流失 Web服务器调用SharePoint服务器上的URL。
  • Use ajax and the JQuery load() function from my web sites running off the web server to call urls on the SharePoint server.

注意:

  • 这似乎是它应该是可以设置的SharePoint服务器 允许仅通过设置交叉起源的请求 访问控制 - 允许 - 产地,它的所有内部并为我高兴,我可以改变web.configs或IIS设置
  • 这可能吗?如果是这样,我在哪里设置。我已经在这读了很多 而似乎无法得到明确的答案。
  • This seems like it should be possible to set the SharePoint server to allow cross origin requests by just setting the Access-Control-Allow-Origin, it's ALL INTERNAL and I can change the web.configs or IIS settings as I please
  • Is this possible? If so, where do I set it. I have read a lot on this and can't seem to get a clear answer.

code:(在我的网页上运行 internalWeb.company.com

CODE: (on my web page running on internalWeb.company.com)

$("#details").load("SharePoint.company.com/someDetails.html");

谢谢!

推荐答案

一个速战速决可能是在您的SharePoint web.config中设置自定义标题:

A quick fix could be to set a custom header in your SharePoint web.config:

<一个href="http://www.iis.net/configreference/system.webserver/httpprotocol/customheaders">http://www.iis.net/configreference/system.webserver/httpprotocol/customheaders

<customHeaders>
    <add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>

或者只是域,尝试

Or for just that domain, try

<customHeaders>
    <add name="Access-Control-Allow-Origin" value="http://internalWeb.company.com" />
</customHeaders>

这篇关于改变访问控制 - 允许 - 原产地,让jQuery的load()来工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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