简体   繁体   English

firefox中的Ajax - 无法在网上找到解决方案

[英]Ajax in firefox - can't find solution on the net

this is my js code: 这是我的js代码:

 $(document).ready(function (e) { $("#f1").on('submit',(function(e) { var ActionType = getParameterByName('t'); var projId = getParameterByName('pj'); var QsId = getParameterByName('s'); var urlString = "uploader.php?t="; urlString +=ActionType; urlString +="&pj="; urlString +=projId; urlString +="&s="; urlString +=QsId; //e.preventDefault(); $.ajax({ url: urlString, type: "POST", data: new FormData(this), contentType: false, cache: false, processData:false, success: function(data) { //alert(callback); //Need to be changed } }); })); }); //This function gets the parameter in the URL (GET) by name function getParameterByName(name) { name = name.replace(/[\\[]/, "\\\\[").replace(/[\\]]/, "\\\\]"); var regex = new RegExp("[\\\\?&]" + name + "=([^&#]*)"), results = regex.exec(location.search); return results === null ? "" : decodeURIComponent(results[1].replace(/\\+/g, " ")); } 

Firebug: 萤火虫: 错误Firebug

Accept / Accept-Encoding gzip, deflate Accept-Language en-US,en;q=0.5 Content-Length 1198 Content-Type multipart/form-data; 接受/接受编码gzip,deflate Accept-Language en-US,en; q = 0.5 Content-Length 1198 Content-Type multipart / form-data; boundary=---------------------------266932244324698 User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0 X-Requested-With XMLHttpRequest boundary = --------------------------- 266932244324698 User-Agent Mozilla / 5.0(Windows NT 6.1; WOW64; rv:30.0)Gecko / 20100101 Firefox / 30.0 X-Requested-With XMLHttpRequest

I really can't understand the problem. 我真的无法理解这个问题。 Everything works perfect in Chrome and IE but not in FF 一切在Chrome和IE中都很完美,但在FF中则不然

EDIT : 编辑 编辑

XHR RESPONE: XHR RESPONE:

 <html> <head> <title>UPLOAD</title> <link href="styles.css" rel="stylesheet" type="text/css"> <script language="javascript" src="scripts.js"></script> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> <script type="text/javascript" src="General.js"></script> </head> 

The rest is the html code for the table and etc.. It is the respone Header 其余的是表等的html代码。它是respone Header

Cache-Control private Content-Encoding gzip Content-Length 1151 Content-Type text/html Date Thu, 26 Feb 2015 21:38:16 GMT Server Microsoft-IIS/7.5 Vary Accept-Encoding X-Powered-By ASP.NET X-Powered-By-Plesk PleskWin 缓存控制私有内容编码gzip内容长度1151内容类型文本/ html日期星期四,2015年2月26日21:38:16 GMT服务器Microsoft-IIS / 7.5不同的接受编码X-Powered-By ASP.NET X- Powered by By Plesk PleskWin

You have the form submitting and you are also have the race condition of the Ajax request. 您有表单提交,并且您也有Ajax请求的竞争条件。 You need to cancel the form submission. 您需要取消表单提交。

$("#f1").on('submit', function(e) {
    e.preventDefault();
});

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

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