简体   繁体   中英

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

this is my js code:

 $(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; 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

EDIT : 编辑

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

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

You have the form submitting and you are also have the race condition of the Ajax request. You need to cancel the form submission.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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