Am working with IONIC were am trying to call a simple login webservice,But unable to pass the required header and body parameters of the service from IONIC code.
curl request of the webservice:
curl -v -H "Accept: application/json" -H "Content-Type:application/json" -H "ModifiedOn:0" -H "username:vikash|214057357158656" -H "password:gbadmin" -d '{"username":"vikash|214057357158656","password":"gbadmin"}' http://localhost:8282/services/Login3.0
Response:
{"ResponseJSON":{"Body":{"Datalist":{"Authentication":"true"}}}}
My IONIC Code:
$scope.login = function() {
$http.post(":8282/services/Login3.0", {"username":"vikash|214057357158656","password":"gbadmin"},"Accept: application/json" -H "Content-Type:application/json" -H "ModifiedOn:0" -H "username:vikash|214057357158656" -H "password:gbadmin");
how to pass the parameters in the IONIC code and get response from the web service.
Am working with IONIC were am trying to call a simple login webservice,But unable to pass the required header and body parameters of the service from IONIC code.
curl request of the webservice:
curl -v -H "Accept: application/json" -H "Content-Type:application/json" -H "ModifiedOn:0" -H "username:vikash|214057357158656" -H "password:gbadmin" -d '{"username":"vikash|214057357158656","password":"gbadmin"}' http://localhost:8282/services/Login3.0
Response:
{"ResponseJSON":{"Body":{"Datalist":{"Authentication":"true"}}}}
My IONIC Code:
$scope.login = function() {
$http.post("http://redmine.youtility.in:8282/services/Login3.0", {"username":"vikash|214057357158656","password":"gbadmin"},"Accept: application/json" -H "Content-Type:application/json" -H "ModifiedOn:0" -H "username:vikash|214057357158656" -H "password:gbadmin");
how to pass the parameters in the IONIC code and get response from the web service.
Share Improve this question asked May 20, 2016 at 6:17 NagNag 3772 gold badges13 silver badges28 bronze badges1 Answer
Reset to default 3Take a look at this, here i have given a sample post method for you requirement.
var userDetails = {
"username":"vikash|214057357158656",
"password":"gbadmin"
}
$scope.login = function() {
$http.post("http://redmine.youtility.in:8282/services/Login3.0",userDetails)
.success (function(response){
console.log(response);
}
.error(function(response){
console.log(response);
};
}
For more details take a look this angular website for $http .
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745467838a4628994.html
评论列表(0条)