我正在尝试使用jQuery发送帖子请求,以便在发送表单之前检查双打,但它仅适用于FireFox浏览器。有人知道问题是什么吗?
这是一个不同的脚本,但是同样的结果,我也测试了它,我遇到了同样的问题:https://www.youtube.com/watch?v=ug1xl379Yi8
<script type = "text/javascript" >
$(document).ready(function() {
$("#file").change(function() {
var file = $("#file").val();
$.post("filedoublecheck.php", {
file: file
}, function(output) {
if (output == 1) {
alert("File already exists!");
}
});
});
});
</script>
**General**:
Remote Address:0.0.0.0:443
Request URL:https://example.net/filedoublecheck.php
Request Method:POST
Status Code:200 OK
**Response Headers**:
Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection:close
Content-Encoding:gzip
Content-Length:20
Content-Type:text/html; charset=ISO-8859-1
Date:Tue, 07 Apr 2015 18:12:26 GMT
Expires:Thu, 19 Nov 1981 08:52:00 GMT
Pragma:no-cache
Server:Apache/2.2.22 (Debian)
Vary:Accept-Encoding
X-Powered-By:PHP/5.3.3-7+squeeze19
**Request Headers**:
Accept:*/*
Accept-Encoding:gzip, deflate
Accept-Language:de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
Connection:keep-alive
Content-Length:92
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
Cookie:******
Host:example.net
Origin:https://example.net
Referer:https://example.net/upload.php
User-Agent:Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36
X-Requested-With:XMLHttpRequest
谢谢!
答案 0 :(得分:0)
我有解决方案......它不能处理文件输入。我为隐藏的输入创建了一个捕获函数,现在它可以工作......
<script type="text/javascript">
$(document).ready(function() {
$("#file").change(function() {
var file = $("#dispName").val();
$.post("filedoublecheck.php", {
file: file
}, function(output) {
if (output == 1) {
alert("File already exists!");
}
});
});
});
function getStats(fName) {
fullName = fName;
shortName = fullName.match(/[^\/\\]+$/);
document.forms.upload.dispName.value = shortName
}
</script>
<input type="hidden" name="dispName" id="dispName" />
&#13;