gpt4 book ai didi

javascript - 如何从 $.getJSON 函数返回值?

转载 作者:行者123 更新时间:2023-11-29 20:15:38 24 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
How to return value from $.getJSON

        function get_url(){
var returnValue = null;
$.getJSON('http://127.0.0.1:1337/?callback=?&command=get_url', "", function(data){
data = $.parseJSON(data);
returnValue = data[0].get_url;
console.log(returnValue); // "not_null"

});
console.log(returnValue); // "null"
return returnValue;
}

为什么函数不返回“not_null”?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com