AJAX XMLHtt prequest POST [英] AJAX XMLHttpRequest POST
本文介绍了AJAX XMLHtt prequest POST的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图写一个XMLHtt prequest使用POST方法。我已成功使用GET方法使用XMLHtt prequest在过去,但我在努力用POST。
I'm trying to write an XMLHttpRequest using the POST method. I have managed to use XMLHttpRequest in the past using the GET method but am struggling with POST.
下面是我的code:
var xmlhttp = null;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
var url = "http://www.mysite.com/script.php";
var params = "var=1";
xmlhttp.open("POST", url, true);
xmlhttp.send(params);
基本上,它调用一个PHP脚本,然后增加了一些信息到数据库。
It basically calls a PHP script which then adds some information to a database.
推荐答案
好吧,我已经成功地排序。
Okay I've managed to sort it.
奇怪的原因,虽然,可能是沙箱安全相关,但不是拥有完整的URL地址,我刚使用相对路径的文件,现在它的作品。
Odd reason though, might be sandbox security related, but rather than have the full URL address, I have just used the relative path to the file, and now it works.
感谢大家的支持。
这篇关于AJAX XMLHtt prequest POST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文