Let me first talk about the problems we encountered today.
A process of exporting excel requires transferring a large amount of data to the background after pressing the button. The initial approach is as follows:
Copy the code code as follows:
var actionUrlSetData = "****Action!exportDatas.action"+ "?now=" + new Date().getTime();
window.location.href= actionUrl + "&" + data;
The data above is a very long string.
There is no problem in Firefox and Google Chrome, but it cannot be exported normally in IE9 (I haven’t tried it in other IEs, it should be the same).
The reason for this problem is that various browsers have different length limits for URL parsing. IE has the smallest one, so something went wrong.
Microsoft Internet Explorer (Browser)
The maximum limit of URLs in IE browser is 2083 characters. If this number is exceeded, the submit button will not respond.
Firefox (Browser)
URL length limit for Firefox browser is 65,536 characters
Safari (Browser)
The maximum URL length limit is 80,000 characters.
Opera (Browser)
The maximum URL length limit is 190,000 characters.
Google(chrome)
The maximum length of the url is limited to 8182 characters
Also note here that the WEB server also has restrictions on the length of the URL! !
Therefore, we cannot use the Get method. We can only find a way to use post to pass the value, so we have the following solution. I am not sure whether it is appropriate or not. I would like to ask an expert for guidance. In short, the function can be realized.
The idea is to use post to transfer the long string to the background, save it in the session, and then use window.location.href in the post callback method.
The code is as follows:
Copy the code code as follows:
$.post(actionUrlSetData,mapList,function(){
var actionUrl = path + "/***action!exportDatas.action"+ "?now=" + new Date().getTime();
window.location.href= actionUrl + "&" + (data);
});