简体   繁体   English

AngularJs。 在$ http.success中调用jQuery函数

[英]AngularJs. Call jQuery function in $http.success

I have a jQuery function to work with the ajax response from the server. 我有一个jQuery函数来处理来自服务器的ajax响应。

$(function () {
    window.ajaxHandler = function (success, userDenied) {
         ....
    });
});

And I have AngularJs function which is called on ng-click. 我有AngularJs函数,可以在ng-click上调用它。

$scope.topActions = function(httpUrl) {
     $http.get(httpUrl).
        success(function(data, status) {
                ajaxHandler(function (data) {
                   console.log(data);
                });
            });
       });
};

Don't understand how to call the function ajaxHandler success inside 不了解如何在内部成功调用函数ajaxHandler

I'm not sure why you need to process the ajax response via jQuery method. 我不确定为什么您需要通过jQuery方法处理ajax响应。 When you can do the same in success method of angular. 当您可以success执行相同的方法时。 Anyways, just to process the server response, you just need to pass the data like below: 无论如何,仅为了处理服务器响应,您只需要传递如下数据:

$http.get(httpUrl).
        success(function(data, status) {
            ajaxHandler(data, status);
         });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM