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: *');
    
    评论

报告相同问题?

悬赏问题

  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办