gpt4 book ai didi

javascript - 在成功登录后运行 HTTP post

转载 作者:可可西里 更新时间:2023-11-01 17:05:32 26 4
gpt4 key购买 nike

我有一个简单的登录,一旦用户登录,我就添加了一个回调来运行另一个帖子,这样我就可以访问帖子 json 以在我的系统中使用。

我认为我的做法是正确的,但是我收到了错误

GetData is not defined

这是正确的做法吗

JavaScript

   $scope.LogIn = function () {
$http({
url: "http://www.somesite.co.uk/ccuploader/users/login",
method: "POST",
data: $.param({'username': $scope.UserName, 'password': $scope.PassWord}),
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}).then(function (response) {
// success
console.log('success');
console.log("then : " + JSON.stringify(response));
GetData();
// location.href = '/cms/index.html';
}, function (response) { // optional
// failed
console.log('failed');
console.log(JSON.stringify(response));
});
};


$scope.UserData = function ($scope) {
$scope.UserName = "";
$scope.PassWord = "";
};

$scope.GetData = function () {
$http({
url: " http://www.somesite.co.uk/ccuploader/campaigns/getCampaign",
method: "POST",
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}).then(function (response) {
// success
console.log('you have received the data ');
console.log("then : " + JSON.stringify(response));
location.href = '/cms/index.html';
}, function (response) { // optional
// failed
console.log('failed');
console.log(JSON.stringify(response));
});
};

最佳答案

您需要将代码更新为 $scope.GetData();

目前您正在使用 GetData(),它没有引用相同的方法。事实上,根据错误消息,它是 undefined

关于javascript - 在成功登录后运行 HTTP post,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46408680/

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