[不是问题,代码转储]如何使用Jquery调用远程Web服务? [英] [Not a question, code dump] How to call remote web service using Jquery?
本文介绍了[不是问题,代码转储]如何使用Jquery调用远程Web服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我想用Jquery调用远程Web服务?我的代码如下。
< script src = js / jquery-1.3。 2.min.js type = text / javascript > < ; / script >
< script language = javascript 类型 = text / javascript >
$(document).ready(function(){
$('#Save')。click(TestingMethod);
}
);
函数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);
},
错误:函数(e){
$('#status')。html =不可用;
}
});
}
< / script >
< / head >
< body >
< 表格 id = form1 runat = server >
< 输入 类型 = text id = txtBizName / >
< 输入 类型 = 按钮 id = 保存 值 = 保存 / >
< div id = status > ;
< / div >
< / form >
< / body >
< / html >
解决方案
(document).ready(function(){
( '#保存')点击(TestingMethod)。
}
);
函数TestingMethod(){
var BizName =
('#txtBizName')。val();
var webMethod =http://MyWebService/offlinecourse.asmx/TestingMethod;
var parameters ={str:'+ BizName +'};
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>
解决方案
(document).ready(function() {
('#Save').click(TestingMethod); } ); function TestingMethod() { var BizName =
('#txtBizName').val(); var webMethod = "http://MyWebService/offlinecourse.asmx/TestingMethod"; var parameters = "{str:'" + BizName + "'}";
这篇关于[不是问题,代码转储]如何使用Jquery调用远程Web服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文