jquery - Assigning ajax response to a variable? -


इस सवाल का पहले से ही एक उत्तर है: < / P>

  • 21 उत्तर

    मैं यहाँ क्या गलत कर रहा हूँ ? <पूर्व> var देश = फ़ंक्शन () {var tmp = null; $ .एजेक्स ({'एसिंक': गलत, 'डेटा टाइप': 'जेएसएनपी', 'यूआरएल': "http://ipinfo.io", 'सफलता': फ़ंक्शन (डेटा) {tmp = data.country;}} ); वापसी टीएमपी; } (); console.log (देश);

    प्रिंट null

    async गलत पर सेट है, इसलिए इसे कार्य करना चाहिए?

    यदि मैं console.log (data.country) डालता हूं, तो सफलतापूर्वक कॉल करने पर BTW

    async: false jsonp अनुरोधों के साथ काम नहीं करेगा

    async सेटिंग के लिए देखें।

    लेकिन वास्तव में, आपको async: false वैसे भी से बचना चाहिए। < / div>

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -