$http post 取不到数据

默认情况下,jQuery传输数据使用Content-Type: x-www-form-urlencoded 和类似于"foo=bar&baz=moe"的序列,然而AngularJS,传输数据使用Content-Type: application/json和{ "foo": "bar", "baz": "moe" }这样的json序列。

$http({
    method: 'POST',
    url: '',
    data: serializeParam({
        "a": 'a',
        "b": JSON.stringify([1,2,3])
    }),
    headers: {
        "Content-Type": "application/x-www-form-urlencoded;charset=utf-8"
    }
}).success(function(json) {
}).error(function() {})
$http({
    method: 'GET',
    url: '',
    params: {
        "a": 'a',
        "b": 'b'
    }
}).success(function(json) {
}).error(function() {})
原文地址:https://www.cnblogs.com/jzm17173/p/6288626.html