Ajax internal values cannot be invoked outside of reason and resolution _AJAX related

Source: Internet
Author: User

Reasons that cannot be invoked outside Ajax internal values and how to solve them

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)//Here Come out is the {}
      })
      Console.log (ID); it's 123 out here.
The problem is on the Ajax async sync Step option, if the async:false is to be run synchronously, the AJAX load completes and then executes the following statement. If Async:turn, it means asynchronous execution, and Ajax will have a chance to entertain the next step of Ajax when the value is not on the line.

The above Ajax internal value outside of the call reason and solution is small series to share all the content, hope to give you a reference, also hope that we support cloud habitat community.

Related Article

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.