无法使用$ HTTP POST方法在数组键发送特殊符号在AngularJS [英] Unable to send special symbols in array keys using $http POST method in AngularJS
本文介绍了无法使用$ HTTP POST方法在数组键发送特殊符号在AngularJS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
无法使用$ HTTP POST方法在数组键发送特殊符号在AngularJS
下面是我的AngularJS code:
VAR的HTTPHeader = {
标题:{内容类型:应用程序/ x-WWW的形式urlen codeD; }
};
VAR POSTDATA = {'USER_ID =!':1};
$ http.post(HTTP://本地主机/ API /浏览/国家,$ httpParamSerializer(POSTDATA)的HTTPHeader)
。然后(功能(响应){
VAR数据= response.data;
});
在PHP当我这样做:
的var_dump($ _ POST);
它表明:
阵列(1){
[0] =>
串(1)为1
}
应该是这样的:
阵列(1){
[user_id说明=!=>
串(1)为1
}
当我没有把它!=它工作正常。我应该怎么做来解决这个?谢谢
解决方案
< PHP$常用3 = 1 [user_id说明=!];//打印$ ARR的所有元素
的print_r($ ARR);呼应'< BR />'$改编[user_id说明=!]。
运行上面的code。我认为user_id说明!=不是指标名称的问题,因为它工作正常。
Unable to send special symbols in array keys using $http POST method in AngularJS
Here is my AngularJS Code:
var httpHeader = {
headers: { 'Content-Type': "application/x-www-form-urlencoded;" }
};
var postData = { 'user_id !=': 1 };
$http.post("http://localhost/api/view/country", $httpParamSerializer(postData), httpHeader)
.then(function (response) {
var data = response.data;
});
in PHP when i do:
var_dump($_POST);
it shows:
array(1) {
[0]=>
string(1) "1"
}
it should be like:
array(1) {
[user_id !=]=>
string(1) "1"
}
When i send it without "!=" it works fine. What should i do to sort out this? Thanks
解决方案
<?php
$arr["user_id !="] = 1;
// Print all the elements of $arr
print_r($arr);
echo '<br/>'.$arr["user_id !="] ;
Run the above code. I think "user_id !=" is not a problem of index name as it works fine.
这篇关于无法使用$ HTTP POST方法在数组键发送特殊符号在AngularJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文