This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
AngularJS has different request data format from Jquery when send almost same post call #6039
Closed
Description
I was tried to use AngularJS $http and coffeescript to send a cross domain post request. I've already changed the server side to make it available for cross domain request.
The question is when I was using Angular js to send request I found the request data is different from the request sent by jQuery.
Angular
login: (user, callback)=>
baseUrl = 'http://localhost:3000/api/v1/sessions'
@$http({
method: 'POST',
url: baseUrl,
data: {
"user":{
"email":"wahxxx@gmail.com",
"password":"123456"
}
},
headers:
'Content-Type': 'application/x-www-form-urlencoded'
}).success (result)->
callback(result)
Jquery
$.ajax({
type: "POST",
url: "http://localhost:3000/api/v1/sessions",
data: {
"user":{
"email":"wahxxx@gmail.com",
"password":"123456"
}
},
success: function(){
}
Then it works well, this request data format is what I want.
I don't know whether it's an issue, hope someone can help me out.
There is same question I posted on stackoverflow: http://stackoverflow.com/questions/21400743/angularjs-cant-send-post-request-with-content-typeapplication-json