Harish Chandra  Patel

Harish Chandra Patel

  • 1.7k
  • 93
  • 13.3k

How to call remote web service using Jquery?

Feb 7 2014 8:08 AM
Hi all,
 
I want to call remote web service using Jquery? My code is given below. 
 
<script src="js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function() {
$('#Save').click(TestingMethod);
}
);
function TestingMethod() {
var BizName = $('#txtBizName').val();
var webMethod = "http://MyWebService/offlinecourse.asmx/TestingMethod";
var parameters = "{str:'" + BizName + "'}";
$.ajax({
url: webMethod,
type: "POST",
dataType: "json",
data: parameters,
contentType: "application/json; charset=utf-8",
success: function(msg) {
$('#status').html('Input is : ' + msg.d);
},
error: function(e) {
$('#status').html = "Unavailable";
}
});
}
</script>
</head>
<body>
<form id="form1" runat="server">
<input type="text" id="txtBizName" />
<input type="button" id="Save" value="Save" />
<div id="status">
</div>
</form>
</body>
</html>
 

Answers (1)