angularjs不会使用美元http。用于发送POST方法的jsonp。

时间:2022-06-20 12:30:51

Please, We have been using a lort of examples but none of them send by post method.

拜托,我们一直在用大量的例子,但是没有一个是通过邮寄方式发送的。

We have a lot of services in angularjs posting like this:

在angularjs中我们有很多这样的服务:

            $http.post(url + '/login.php?action=login_user', data).success(function(response, status) {
                callback(response, status);
            }).error(function(response, status) {
                callback(response, status);
            });

Where data allways are JSON data like this or more complex:

数据的所有方式都是JSON数据,比如这个或更复杂的:

            var data = {
                username: username,
                password: password
            };

And we need adap a lot of this calls to a JSONP with the minimum change soo try send data by post as JSON like previos but changing to this (using jsonp)

我们需要adap对JSONP进行大量的调用以最小的更改soo尝试以JSON的形式发送数据,比如previos,但要更改为这个(使用JSONP)

            $http.jsonp(url + '/login.php?action=login_user&callback=JSON_CALLBACK', data).success(function(response, status) {
                callback(response, status);
            }).error(function(response, status) {
                callback(response, status);
            });

But looking the inspector this is not sending the post JSON data. Why?

但是查看检查器,这不是发送post JSON数据。为什么?

Is because $http.jsonp never use POST and only GET method? How can We send our json data object by POST ?

因为美元http。jsonp从不使用POST,只获取方法?如何通过POST发送json数据对象?

We use PHP in the server, We never see an full example using angularjs sending JSONP by post to PHP and we dont know how get the the posting vals in PHP.

我们在服务器中使用PHP,我们从来没有看到一个完整的例子,使用angularjs将JSONP发送到PHP,我们不知道如何用PHP来发布消息。

So in PHP We send a JSON but using the JSONP in angular how must We send form PHP to Angularjs.

在PHP中,我们发送JSON但使用JSONP的角度我们必须如何将PHP形式发送给Angularjs。

Our Web currently is working OK but is not using JSONP in AngularJS but now We need change all for usin JSONP.

我们的Web目前运行良好,但在AngularJS中没有使用JSONP,但是现在我们需要为usin JSONP更改所有内容。

A full simple example with the call from AngularJS and how PH get the post and send JSON would help us a lot because after searching a lot we do not find.

一个来自AngularJS的电话的完整的简单示例,以及PH是如何获得这个帖子并发送JSON的,将对我们有很大的帮助,因为在搜索了很多之后,我们没有找到。

Please, thanks in advance and hope this can help other

请提前谢谢,希望这能对其他人有所帮助

1 个解决方案

#1


0  

I think this will suit you better - a simple post method in AngularJS

我认为这将更适合你-一个简单的邮寄方法在AngularJS

$scope.Executenowbuttons = function () {
    // $scope.datetimess = $filter('date')(new Date(), 'dd-MM-yyyy hh:mm ');
    // console.log(datetimess);
    // alert($scope.today);
    var pullDataUrl = 'http://192.168.1.20:8082/resources/scheduleExecuteJob/scheduleExecuteJob';
    var pullData = {
        "execprogms": "DEDUP",
        "delid": "",
        // "datimevalue": "18-Jul-2017 12:20",
        "datimevalue": $scope.datetimes,
        "userName": "admin"
    };
    $http.post(pullDataUrl, pullData)
        .success(function (data) {
            var msg;
            alert(data.msg)
                // location.reload();
                //$location.path('/Importer/Merge')
                //$scope.getAllDatatreeView();
        })
        .error(function () {
            alert("Session Time out")
        });
};

#1


0  

I think this will suit you better - a simple post method in AngularJS

我认为这将更适合你-一个简单的邮寄方法在AngularJS

$scope.Executenowbuttons = function () {
    // $scope.datetimess = $filter('date')(new Date(), 'dd-MM-yyyy hh:mm ');
    // console.log(datetimess);
    // alert($scope.today);
    var pullDataUrl = 'http://192.168.1.20:8082/resources/scheduleExecuteJob/scheduleExecuteJob';
    var pullData = {
        "execprogms": "DEDUP",
        "delid": "",
        // "datimevalue": "18-Jul-2017 12:20",
        "datimevalue": $scope.datetimes,
        "userName": "admin"
    };
    $http.post(pullDataUrl, pullData)
        .success(function (data) {
            var msg;
            alert(data.msg)
                // location.reload();
                //$location.path('/Importer/Merge')
                //$scope.getAllDatatreeView();
        })
        .error(function () {
            alert("Session Time out")
        });
};