Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What if the internal value of ajax cannot be called externally?

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly shows you the "ajax internal value external call can not do", the content is easy to understand, clear, hope to help you solve the doubt, the following let the editor lead you to study and learn "ajax internal value external call can not do" this article.

The reason why the internal value of ajax can not be called externally and its solution

Var id='123';$.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) / / what comes out here is 100}}) console.log (id); / / what comes out here is 123

The problem lies in the async synchronization guide option of ajax. If async:false is run in synchronous mode, ajax loads and then executes the following statement. If async:turn, it means that the ajax executes asynchronously, and if the ajax does not reach the value, it will have a chance to entertain the next statement of ajax.

The above is all the contents of the article "what to do if the internal value of ajax cannot be called externally". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report