I am trying to send the registration form data to an api that registers the user and provides the success response. I am getting the following error while try to send the data through $http
/ringleader/www/#!/register:1 XMLHttpRequest cannot load
http://72.5.146.113/portal-app/API/addRingLeader/?0=f&1=i&10=s&100=c&101=i&…
87=d&88=g&89=%26&9=%3D&90=p&91=r&92=o&93=d&94=u&95=c&96=t&97=%3D&98=S&99=o.
Response for preflight has invalid HTTP status code 404
Here is my controller
.controller('loginController',function($scope,authService){
$scope.login = function(data){
authService.login(data).then(function(response){
console.log(response.status + " ------ "+JSON.stringify(response));
},function(err){
if (err) {
console.log(err);
}
})
}
})
.controller('registerController',function($scope,authService){
$scope.register = function(data){
authService.register(data).then(function(response){
console.log(response.status + " ------ "+JSON.stringify(response));
},function(err){
if (err) {
console.log(err);
}
})
}
})
and this is my service
.factory('authService',function($http){
return{
register : function(data){
return $http({
url: 'http://72.5.146.113/portal-app/API/addRingLeader/',
method: 'POST',
params: $.param({
firstname : data.firstname,
lastname : data.lastname,
email : data.email,
mobile : data.mobile,
password : data.password,
product : "Social"
}),
dataType: "jsonp",
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
})
},
login : function(data){
return $http({
url: 'http://72.5.146.113/portal-app/API/signIn/',
method: 'POST',
params: $.param(data),
dataType: "jsonp",
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
})
}
}
})