最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to call a simple web service from IONIC - Stack Overflow

programmeradmin1浏览0评论

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 badges
Add a ment  | 

1 Answer 1

Reset to default 3

Take 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 .

发布评论

评论列表(0)

  1. 暂无评论