$http.post 采用postJSON方式发送数据到后台.

  如果不需要发送json格式数据,序列化成&连接的字符串,形如:"a=1&b=2",最终完整的前端解决方案:

var url = 'Gulugulus/setMenu',
            data = {
                menu: JSON.stringify(menu),
                test: 'a String'
            },
            transFn = function(data) {
                return $.param(data);
            },
            postCfg = {
                headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'},
                transformRequest: transFn
            };

        $http.post(url, data, postCfg)
            .success(function(){
                window.location.href = "Gulugulus/subMenu";
            });

 

AngularJS中的$http.post与jQuery.post的区别

jQuery会把作为JSON对象的myData序列化,angularjs 以postJSON方式发送数据到后台.

相关文章:

  • 2021-11-16
  • 2021-06-29
  • 2022-12-23
  • 2021-10-26
  • 2022-12-23
  • 2022-12-23
  • 2021-10-31
  • 2021-10-09
猜你喜欢
  • 2021-12-31
  • 2021-07-09
  • 2022-12-23
  • 2021-06-02
  • 2022-12-23
  • 2021-05-21
相关资源
相似解决方案