首先在页面上写上如下代码:

<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="~/WebServices/PullDataWebService.asmx" />
</Services>
</asp:ScriptManager>

在WebServices的文件夹下建一个PullDataWebService.asmx,如下所示:

<%@ WebService Language="C#" CodeBehind="~/App_Code/PullDataWebService.cs" Class="PullDataWebService" %>

js中调用app_code里面的PullDataWebService.cs类的代码:

var shxm= document.getElementById("xmbh").value;
var shlf= document.getElementById("lpbh").value;
PullDataWebService.FCUpdateData(shxm, shlf,FCCheckCallSuccess);

(FCSaveCallSuccess方法调用几个参数,该方法前面就放几个参数)

PullDataWebService用一个例子来展示写的方法:

[WebMethod]
[ScriptMethod]
public int FCUpdateData(string sslf, string ssxm)
{
string sqlText = "update fdcjy_jyfcxx set t.oc_shbz='T' ,t.oc_shr='" + 1 + "' , t.dt_shsj =to_date('" + DateTime.Now.ToString() + "','yyyy-mm-dd hh24:mi:ss') where t.oc_xmbh='" + ssxm + "' and t.oc_lpbh='" + sslf + "'";
OracleAccessFDCJY orc = new OracleAccessFDCJY();
int i = orc.ReturnRowsofExecute(sqlText);
return i;
}

接收 webservice返回结果的js:

// 回调函数
function FCCheckCallSuccess(returnInt)
{
if (returnInt == "0")
{
alert("未查到信息,请确认后再查询!");
return;
}
else
{
alert("审核通过!");
return;
}
}

posted on 2012-10-31 09:31  求知的我  阅读(256)  评论(0编辑  收藏  举报