jquery - 当 json 字符串中有 & 登录时,http post 请求中的数据中断

标签 jquery angularjs http post

我有一个 json 字符串,字符串在下面。

 {  
   "assigned_to":1,
   "type":0,
   "email":[  
      {  
         "value":"mobile@gmail.com",
         "is_primary":1,
         "type":1,
         "type_id":1
      }
   ],
   "first_name":"Mr Mobile",
   "salutation_id":1,
   "links":[  
      {  
         "company":"Mobile",
         "relation":"CEO & Founder",
         "cmp_id":1
      }
   ],
   "phone":[  
      {  
         "code":"",
         "value":"",
         "is_primary":1,
         "phone_type":"1",
         "country_code_value":""
      }
   ],
   "photo":"",
   "last_name":""
}

当我使用 http 和 post 方法传递此数据时,字符串在 & 符号后断开。

我的http post请求代码是这样的

NOTE: JSON.stringify(this.formData) returns above string

$http.post(APP.API + 'contacts', 'data=' + JSON.stringify(this.formData)).
                    success(function(data, status, headers, config) {


                    }).
                    error(function(data, status, headers, config) {

                        // debugger;
                        Notification.error(data.msg);
                    });

这个请求传递了什么,请看下面的网络截图。 click here

此屏幕截图是在从请求中删除“data=+”之后:click here

数据在关系键 & 之后中断。

请帮我解决这个问题。提前致谢

最佳答案

关于jquery - 当 json 字符串中有 & 登录时,http post 请求中的数据中断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45207329/

相关文章:

javascript - 替换 "templateUrl":path with "template":content for angular directives using gulp

java - 如何执行异步计算并同时处理其他http请求?

c# - 阻止 HttpWebRequest 检查我的负载

http - 如何在 HTTP POST 请求中传递参数?

javascript - AngularJS JQuery Ajax 表单提交等效

javascript - 页面加载时未触发调整大小事件

jquery - 如何删除链接并添加功能

javascript - JS中根据背景颜色切换元素颜色

javascript - AngularJS ng-repeat过滤器性能: custom filter or ng-show/hide

javascript - 在 Angular 1.4.4 中,为什么范围变量的更改会在没有 $watch 或 $apply 的情况下传播到 DOM?