通过Ajax将数据发送到外部文件 [英] Sending data to an external file via Ajax

查看:130
本文介绍了通过Ajax将数据发送到外部文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用此代码时,它可以工作:

When I use this code, it works:

ajax.open("post","a.php",true);

但当我尝试将数据发送到外部文件时:

but when I try to send data to a external file like:

ajax.open("post","http://www.example.com/a.php",true);

它不起作用。

是否有任何解决方案?

推荐答案

必须打开的文件的URL - 服务器端脚本的位置。这可以是绝对URL,如(http://www.foo.com/bar.php)或相对URL(/bar.php)。注意事项 - 此URL应与脚本位于同一域中。您无法通过yahoo.com中运行的脚本在google.com中调用脚本。这是在大多数浏览器中实施的安全措施,以防止XSS。

The URL of the file that must be opened - the location of the server side script. This can be a absolute URL like(http://www.foo.com/bar.php) or a relative one(/bar.php). A note of caution - this URL should be in the same domain as the script is. You cannot call a script in google.com from a script that is running in yahoo.com. This is a security measure implemented in most browsers to prevent XSS.

问候,
Cyril

Regards, Cyril

这篇关于通过Ajax将数据发送到外部文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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