AngularJs $http.post() does not send data

前端 未结 30 1757
我在风中等你
我在风中等你 2020-11-22 02:51

Could anyone tell me why the following statement does not send the post data to the designated url? The url is called but on the server when I print $_POST - I get an empty

30条回答
  •  清酒与你
    2020-11-22 03:27

    this is probably a late answer but i think the most proper way is to use the same piece of code angular use when doing a "get" request using you $httpParamSerializer will have to inject it to your controller so you can simply do the following without having to use Jquery at all , $http.post(url,$httpParamSerializer({param:val}))

    app.controller('ctrl',function($scope,$http,$httpParamSerializer){
        $http.post(url,$httpParamSerializer({param:val,secondParam:secondVal}));
    }
    

提交回复
热议问题