2014-07-16 16 views
0

我的问题很简单,每次我尝试传递一个带有特殊字符的字符串,通过一个 $ http.get()查询,一些特殊字符被删除。

就我而言,简单的电子邮件:[email protected],在查询标题中成为emmawatson.com。

Angular在发送AJAX查询之前进行某种验证?

这里是我的Ajax代码:

$http.get(apiUrl, 
      { 
       params: { 
        username: "Emma", 
        email: "[email protected]", 
        password: "1234" 
       } 
      }) 
      .success(function(data) { 
       //do a simple return of the email on the server 
       console.log(data);//"emmawatson.com" 
      }); 

回答

1

HTTP请求,强烈建议为Base64发送之前编码数据。

试试这个代码,看看它的工作原理:

$http.get(apiUrl, { 
    params: { 
     username: "Emma", 
     email: window.btoa("[email protected]"), 
     password: "1234" 
    } 
}) 
.success(function (data) { 
    //do a simple return of the email on the server 
    console.log(data); //"emmawatson.com" 
}); 
+0

非常感谢,这个解决我的问题,在服务器端解码:) – Najie

+0

没问题,我很乐意帮忙。请考虑接受这个答案:) –