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.

Source: Internet
Author: User

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 );}}});

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.