前台用ajax :javascript
var result = false; $.ajax({ type: "Post", url: "KYGL_QT_Search.ashx", data: "flowsn="+flowsn, async: false, error: function () { alert('链接超时'); }, success: function (data) {//data为本身定义的返回值 if (data == "true") { alert('该矿已经抵押3次'); } else { result = true; } } });
创建 ashx 交互文件:java
public void ProcessRequest(HttpContext context) { string flowsn = context.Request["flowsn"]; string result = "false"; string sql = ""; int count =Convert.ToInt32( DbFactory.Instance.GetDbHelp().ExecuteScalar(sql)); if (count >= 3) { result = "true"; } context.Response.ContentType = "text/plain"; context.Response.Write(result); }