douwendu2460 2015-09-23 10:08
浏览 69

如何通过本地PHP文件对远程服务器进行跨域Ajax调用

I need to make a post call to a RDF graph, updating some data. If I use Ajax in jQuery and call directly the service, I get a 'No 'access-control-allowed-origin' ecc.ecc.' warning in console, but the update is successful.

I know that this worning is due to the same-origin policy, and I 'avoid' it in 'GET' calls using 'jsonp' format; I don't know how to avoid it in 'POST' calls. After some research online, I found out that client-side the only solution (if you don't have access to the server code, as in my case) is to use an IFrame snippet; I can't for many reasons.

The only solution that remains to me is to make the Ajax call to a local PHP file (as I already do for other reasons) and then from there contact the remote server and make the 'POST' call.

Does anyone know if there are other ways? If not, do you have any idea on how to make a cross-domain post call from php?

  • 写回答

1条回答 默认 最新

  • doucong7963 2015-09-23 10:16
    关注
    header('Access-Control-Allow-Origin: *');
    
    评论

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效