Deepali Patil

Deepali Patil

  • NA
  • 4
  • 2.8k

hitting web service from other system using ajax

Feb 21 2014 12:42 AM
Hi,

  I  am trying to hit one of the web service which is located at different system so at that system hit is going and authentication as true is also coming and data in console is getting displayed ,but the data is not getting displayed as success popup in my system directly cursor is going to failure function it is not going in success function.and error is coming and in staus pending as well as data as cancelled is getting displayed while debugging.

  And I have created one web service in my system and using that url as localhost I am getting pop up as success .these all is done using ajax along with jquery ,The below is code displayed.all ports of other system are opened in my system and domain is same for both.

<html>
  <head>
  <title></title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <!--  <script type="text/javascript" src="jquery-1.10.2.min.js"></script>-->
  <script type="text/javascript" src="jquery-1.8.3.min.js"></script>
<script>

  function doAjaxCallText(  ajaxparam1, ajaxparam2,ajaxparam3, ajaxparam4, ajaxtype)
  {
  var ajaxresponse="";
  $.ajax({
  url:'http://some other system url where that service is located',
  //  url: 'http://localhost:8080/DemoService/Service1' ,(my system url where i have created one demo service )
  type: 'POST',
  data: {username: ajaxparam1, password: ajaxparam2, deviceId: ajaxparam3, param4: ajaxparam4},
  contentType:"application/x-www-form-urlencoded; charset=UTF-8",
  //contentType:"text/plain",
  dataType:"text",
  cache: false,
  crossDomain: true,
  success: function(response) {
  ajaxresponse=response;
  alert(response);
  alert('hi');
  alert(ajaxresponse+'-----');
},
  error: function (XMLHttpRequest, textStatus, errorThrown) {
  alert("An error has occurred making the request: " + errorThrown.toString());
  }
  });

  alert(ajaxresponse);
  }
  </script>
</head>
  <!--  <body onload="doAjaxCallText()">-->
  <body onload="">
  <input type="button" name="click" onclick="doAjaxCallText('101', 'Pass@123', 'abc','', 'POST')" value="click">
  <!--  <body onload="xyz()">-->
  <div id="jqxgrid"></div>
  </body>


please see it and let me know the solution. same is the case by using angularjs with ajax for calling web service there I have tried data type as json also because they are displaying result in json but no effect .