How do I POST urlencoded form data with $http without jQuery?

后端 未结 11 2387
生来不讨喜
生来不讨喜 2020-11-21 23:27

I am new to AngularJS, and for a start, I thought to develop a new application using only AngularJS.

I am trying to make an AJAX call to the server side, using

11条回答
  •  难免孤独
    2020-11-22 00:24

    you need to post plain javascript object, nothing else

               var request = $http({
                    method: "post",
                    url: "process.cfm",
                    transformRequest: transformRequestAsFormPost,
                    data: { id: 4, name: "Kim" }
                });
    
                request.success(
                    function( data ) {
                        $scope.localData = data;
                    }
                );
    

    if you have php as back-end then you will need to do some more modification.. checkout this link for fixing php server side

提交回复
热议问题