TypeError:$ .get不是函数

时间:2018-02-14 00:06:12

标签: javascript jquery

我有一个JavaScript函数。

$scope.getBanksyUrl = (data) => {
    $.get('banksyurlservlet', function(data) {
        //return the url here
    });
}; 

但是当我调用这个函数时,我在JS控制台中看到了:

TypeError: $.get is not a function
    at Scope.$scope.getBanksyUrl (http://admin.gearlaunch-dev.com:8080/js/admin/campaignModule.js:136:8)
    at fn (eval at compile (http://admin.gearlaunch-dev.com:8080/jspm_packages/github/angular/bower-angular@1.5.8/angular.js:25885:17)
    at Scope.$eval (http://admin.gearlaunch-dev.com:8080/jspm_packages/github/angular/bower-angular@1.5.8/angular.js:17682:28)
    at Scope.$apply (http://admin.gearlaunch-dev.com:8080/jspm_packages/github/angular/bower-angular@1.5.8/angular.js:17782:25)
    at HTMLAnchorElement.eval (http://admin.gearlaunch-dev.com:8080/jspm_packages/github/angular/bower-angular@1.5.8/angular.js:25890:23)
    at defaultHandlerWrapper (http://admin.gearlaunch-dev.com:8080/jspm_packages/github/angular/bower-angular@1.5.8/angular.js:3497:11)
    at HTMLAnchorElement.eventHandler (http://admin.gearlaunch-dev.com:8080/jspm_packages/github/angular/bower-angular@1.5.8/angular.js:3485:9)
    at HTMLAnchorElement.wrapped (http://admin.gearlaunch-dev.com:8080/jspm_packages/github/getsentry/raven-js@3.3.0/dist/raven.js:351:29) undefined

我目前做错了什么?

1 个答案:

答案 0 :(得分:0)

尝试使用jQuery代替$。其他库可以覆盖$

此外,最好使用angularJs $HTTP service。例如。: $http.get("welcome.htm").then(function(response) { $scope.myWelcome = response.data; });

您可以阅读更多here, in AngularJs docs