Solve the problem that some browsers submit data via ajax, but the data has changed, but the data received by the background is still the last value.
Recently, I encountered the problem that the QQ browser submitted data via ajax, the form data changed, but the background data received data was still the last value, but it was normal in other browsers.
The Code is as follows: $. ajax ({url: "<% = path %>/secretkey/uploadKey", async: false, type: 'post', data: {merKey: $ ('# merkey '). val (), keyType: $ ('# keytype '). val (), type: $ ('# type '). val ()}, success: function (data) {if (data. success = 'undefined' | data. success = null) {if (data. indexOf ("") >=0) {window. open ('<% = path %>/common/error? Type = login ',' _ self ') ;}} if (data. success = true) {_ alert (data. message); $ ("# merKey "). val (""); $ ("# keyType "). val (""); closeDilog ();} else {_ alert (data. message );}}});
Check the $. ajax source code and find that the default value of the cache parameter is true, which means that the entire request and data are cached by default. By changing the cache value to false, data and requests are not cached,
Test data in the QQ browser and other browsers.
The Code is as follows:
$.ajax({url : "<%=path%>/secretkey/uploadKey",async:false,cache:false,type : 'post',data : {merKey : $('#merKey').val(),keyType : $('#keyType').val(),type : $('#type').val()},success : function(data) {if(data.success=='undefined'||data.success==null){if(data.indexOf("") >=0) {window. open ('<% = path %>/common/error? Type = login ',' _ self ') ;}} if (data. success = true) {_ alert (data. message); $ ("# merKey "). val (""); $ ("# keyType "). val (""); closeDilog ();} else {_ alert (data. message );}}});