Angularjs的$http get方法不发送任何参数


Angularjs $http get method not sending any params

我创建了一个jsfiddle,如果我试图在单击测试按钮时使用$http执行http get,语法和$http的结构。Get对我来说似乎是正确的,但它没有在url中发送选定的参数(查询字符串{data:$scope.newuser})。

小提琴来了:

jsfiddle.net/8sZLs/2/

在php端我尝试了,但不显示张贴的值

您不能使用get发送对象,您需要像下面这样发出post请求。

 $http({
   url: 'request-url',
   method: "POST",
   data: { 'message' : message }
})

正如@YauheniLeichanok所建议的,另一种方法是使用查询参数,params$http.get,在这种情况下,您传递的字符串将显示为:?key1=value1&key2=value2

替换$http。Get line with this

$http.get('/echo/html/', {params:$scope.newuser});

关于如何在服务器端PHP获取值。

必须使用php标准输入

$data = file_get_contents("php://input");
$objData = json_decode($data);