admin管理员组文章数量:1430689
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 .
本文标签: javascriptHow to call a simple web service from IONICStack Overflow
版权声明:本文标题:javascript - How to call a simple web service from IONIC - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745467837a2659610.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论