Angularjs $ HTTP GET方法不发送任何PARAMS [英] Angularjs $http get method not sending any params

查看:225
本文介绍了Angularjs $ HTTP GET方法不发送任何PARAMS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个的jsfiddle,全被我特林执行HTTP GET使用的$ HTTP上的测试按钮,语法和$结构单击时http.get似乎是正确的我,但它未发送所选PARAMS(查询字符串{数据:$ scope.newuser})。在网址

I have created a jsfiddle, were i am tring to perform a http get using $http when clicked on the test button, The syntax and the structure of $http.get seems correct to me, but it is not sending the selected params (query string {data:$scope.newuser}) in the url.

这里是提琴:

jsfiddle.net/8sZLs/2 /

jsfiddle.net/8sZLs/2/

而在PHP端我尝试

但没有显示张贴的值

And at php side i tried , But not showing the values posted

推荐答案

您不能用GET发送一个对象,你需要做一个POST请求如下。

You cannot send an object with get, you need to make a post request as following.

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

由于@YauheniLeichanok建议,另一种方法是使用查询参数, PARAMS $ http.get ,在这种情况下,通过将显示为字符串:<?code>键1 =值&放大器;键2 =值

As @YauheniLeichanok suggested, another way is to use query parameters, params of $http.get, in this case the strings you pass will appear as: ?key1=value1&key2=value2

这篇关于Angularjs $ HTTP GET方法不发送任何PARAMS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆