gpt4 book ai didi

javascript - http请求后调用

转载 作者:行者123 更新时间:2023-12-03 08:30:29 25 4
gpt4 key购买 nike

我想在收到数据并存储它后使用一个函数,但是我使用的代码没有得到我想要的结果。

有人可以向我提供一些有关我做错了什么的详细信息吗?

我的代码:

    $http({
method: 'GET',
url: 'JsonLocation'
}).then(
function successCallback(response) {
// this callback will be called asynchronously
// when the response is available.
self.responseData = response.data;
},
function errorCallback(response) {
// called asynchronously if an error occurs
// or server returns response with an error status.
console.log(response);
}
).then(
function completeCallback() {
// called when the http request is finished.
restyleData();
}
);

当页面加载并且一切都设置到位后,我可以通过开发人员选项运行restyleDate(),然后它就可以工作了。但我只想在加载所有内容后触发它,而不是手动执行。

最佳答案

我建议更改为:

$http({
method: 'GET',
url: 'JsonLocation'
}).then(
function successCallback(response) {
// this callback will be called asynchronously
// when the response is available.
self.responseData = response.data;
// restyle is called after you save the result
restyleData();
},
function errorCallback(response) {
// called asynchronously if an error occurs
// or server returns response with an error status.
console.log(response);
}
);

关于javascript - http请求后调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33354869/

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