angular post发送请求和GET发送请求,服务器端接收不到信息的问题

参数可能因为编码原因,服务器端无法接收到传递的值,

这时需要用到补丁来解决这个问题

1,下载一个http.patch.js文件,放入YII框架中的js/ng文件架内

2angularjs 创建模型部分使用这个补丁,var app=angular.module('MyApp',[],http_patch);

 

整体代码如下

var app=angular.module('MyApp',[],http_patch);

app.controller('LoginController',['$scope','$http',function($scope,$http){
$scope.loginTo=function(){
var emaillVal=$scope.email;
var pwdVal=$scope.pwd;

$http({
data:{'email':emaillVal,'password':pwdVal},
url:'/myTest/testFrom',
method:'POST'
// headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}).success(function(data){
console.log(data);
}).error(function(){
alert("回掉!错了");
});
}
}]);

posted @ 2014-04-14 13:41  粉条  Views(710)  Comments(0)    收藏  举报