<script src="Scripts/jquery-1.11.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#Button1").click(function () {
try {
$.ajax({
type: "POST", //访问WebService使用post方式请求
contentType: "application/json;utf-8", //WebService会返回json类型
url: "http://localhost:8321/WebService.asmx/HelloWorld", //调用WebService的地址和方法名称组合
data: "{userName:'Jodie'}", //这里是要传递的参数,格式为data:"{paraName:paraValue}"
dataType: "json",
success: function (result) {
$("#result").html(result.d);
alert(result.d);
}
})
}
catch (ex) {
alert(ex);
}
})
})
</script>
jquery调用webservice
最新推荐文章于 2020-11-28 17:03:00 发布