Causes and solutions for external calls of ajax Internal Values
Causes and solutions for external calls of ajax Internal Values
Var id = '000000'; $. ajax ({url: 'http: // www.xxx.com/ajax', type: 'post', dataType: "json", data: {wurl: w_url, murl: m_url}, async: turn, error: function () {}, success: function (data) {var id = data ['id']; console. log (id) // here the output is 100}) console. log (id); // The output here is 123
The problem lies in the async synchronization step option of ajax. If async: false is used, the synchronization mode is used. After ajax is loaded, the following statement is executed. If async: turn, it indicates asynchronous execution. If ajax is not set to a value, it will have the opportunity to entertain the next ajax statement.
The reason why the above ajax internal values cannot be called externally and the solution is all the content that I share with you. I hope to give you a reference and support for the customer's house.