我想用ajax在服务器上调用webmethod [英] I want call webmethod on the server with ajax
本文介绍了我想用ajax在服务器上调用webmethod的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何用ajax在页面中调用web方法
地址是webservice.rgraga.com/GetNews
parametr是Id
解决方案
< script src = http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js 类型 = text / javascript > < / script >
< script 类型 = text / javascript >
函数ShowCurrentTime(){
.ajax({
type:POST,
url:CS .aspx / GetCurrentTime,
数据:'{name:'+
(#<% = txtUserName.ClientID %> )[0] .value +'}',
contentType:application / json; charset = utf-8,
dataType:json,
成功:OnSuccess,
失败:函数(响应){
alert(response.d);
}
});
}
函数OnSuccess(响应){
alert(response.d);
}
< / script >
how to can call web method in the page with ajax
address is webservice.rgraga.com/GetNews
parametr is Id
解决方案
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript"></script> <script type = "text/javascript"> function ShowCurrentTime() {
.ajax({ type: "POST", url: "CS.aspx/GetCurrentTime", data: '{name: "' +
("#<%=txtUserName.ClientID%>")[0].value + '" }', contentType: "application/json; charset=utf-8", dataType: "json", success: OnSuccess, failure: function(response) { alert(response.d); } }); } function OnSuccess(response) { alert(response.d); } </script>
这篇关于我想用ajax在服务器上调用webmethod的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文