简体   繁体   English

Ajax和php重定向

[英]Ajax and php redirection

This is what I try to do: 这是我尝试做的:

  1. server A display a page 服务器A显示页面
  2. javascript in this page call a server A php script with ajax 此页面中的javascript调用服务器和ajax的php脚本
  3. server A script check right and other data 服务器脚本检查权限和其他数据
  4. if all is ok, server A redirect to resource on server B 如果一切正常,则服务器A重定向到服务器B上的资源

Problem : 问题:

I cannot redirect my php answer to ajax, probably due to cross domain protection. 由于跨域保护,我无法将我的php答案重定向到ajax。

What can I do? 我能做什么?

I don't want use file_get_contents because the resource on server B can be quite heavy so I don't want download it twice (once by serverA, second by client) 我不想使用file_get_contents因为服务器B上的资源可能很重,所以我不想两次下载(一次由serverA,一次由客户端)

just get a response from server which consists of js code to redirect you to the required URL 只需从包含js代码的服务器获取响应即可将您重定向到所需的URL

for example 例如

echo "<script> window.location=url_to_redirect;</script> ";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM