Javascript Mootools:拒绝设置不安全的标题“;“连接”;
我试图使用Mootools发送一个简单的ajaxpost请求,但我只收到标题中的错误消息,它似乎没有正确地发送数据(请求被取消) 以下是html:Javascript Mootools:拒绝设置不安全的标题“;“连接”;,javascript,mootools,Javascript,Mootools,我试图使用Mootools发送一个简单的ajaxpost请求,但我只收到标题中的错误消息,它似乎没有正确地发送数据(请求被取消) 以下是html: <form id="form_5" name="form_5" action="someajaxfile.php" onsubmit="jsfunction(this,5);return false;" method="post">....</form> 我曾尝试向send函数添加头:{'X-Request':'JSON'}
<form id="form_5" name="form_5" action="someajaxfile.php" onsubmit="jsfunction(this,5);return false;" method="post">....</form>
我曾尝试向send函数添加头:{'X-Request':'JSON'},
之类的内容,但似乎没有改变错误。有一件事是,在chrome的网络标签下,我可以看到两个请求:
someajax.php
/somefolder
POST
302
Found
text/html
mootools.js:247
Script
354B
0B
2ms
2ms
2ms0
someajax.php
/somefolder
GET
(canceled)
Pending
http://localhost:8888/somefolder/someajax.php
Redirect
13B
0B
0ms
0.0 days
问题是:为什么我不能发送数据,发生了什么,为什么,我的问题有什么好的解决方案
问题是:为什么我不能发送数据,发生了什么,为什么
有什么好办法解决我的问题吗
您的问题是Chrome+Local和--allow file access from files限制的组合
尝试:
- 在chrome(dev)中的“安全”环境中运行这些文件,其中 命令--允许从文件访问文件
- 在其他浏览器中运行文件
function myfunction(form){
new Request({
url:form.action,
data:form,
onSuccess:function(result){
console.log(result);
}
}).send();
return false;
};
这里有一个工作示例:这是什么版本的mootools?。。我不知道您可以直接从表单元素发出请求。。。也许我错了,但如果需要JSON响应,通常需要创建Request类或Request.JSON的实例,甚至是Form.Request。显然,您可以确认它在后台服务器(不是本地主机)上工作,即使显示错误消息。创建Form.Request类的新实例时的问题是生成html。我仍然有兴趣知道是否有人在不太重写函数的情况下解决了我的问题。顺便说一下,办公室里没有人知道它是什么版本:P@pleasedontbelong这是More表单的一部分。Request@dombenoit我不这么认为,在doc
myFormRequest
中,它是表单的一个实例。Request,而不是表单本身
function myfunction(form){
new Request({
url:form.action,
data:form,
onSuccess:function(result){
console.log(result);
}
}).send();
return false;
};