using System.Web.Services;
[WebMethod]
public static string SayHello()
{
return "Hello Ajax!";
}
$(function() {
$("#btn").click(function() {
$.ajax({
type: "post", //要用post方式
url: "Demo.aspx/SayHello",//方法所在页面和方法名
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data) {
alert(data.d);//返回的数据用data.d获取内容
},
error: function(err) {
alert(err);
}
});
});
});
<form id="form1" runat="server"> <div> <asp:Button ID="btn" runat="server" Text="验证用户" /> </div> </form>
$.ajax({
type: "POST",
url: "S_CBFBM.ashx",
data: { ZBM: p_zdm },
beforeSend: function() {
//$("#div_load").visible = "true;
},
success: function(msg) {
//$("#div_load").visible = false;
$("#ds").html("<p>" + msg + "</p>");
$("#CBFBM").val(msg);
}
});
<%@ WebHandler Language="C#" Class="AjaxHandler" %>
using System;
using System.Web;
public class AjaxHandler : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
if (context.Request["name"].ToString() == "admin" &&
context.Request["pass"].ToString() == "admin")
{
context.Response.Write("Y");
}
else
{
context.Response.Write("N");
}
}
public bool IsReusable {
get {
return false;
}
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有