https://www.xp.cn/b.php/27223.html
参考于此
实现一个ajax其实需要两个页面来实现
比作 A页面 和 B页面
在 a页面 =》 使用ajax方法 =》 发送 post请求 =》b页面后台.cs接收并且“处理数据” =》 b页面后台传输数据=》a页面接收
就像 你把骨头仍别家后花园(别家页面后台 ) 让你家狗叼回来 不会经过你家后花园(后台)
就不会刷新 额 打个标记 待精通后回来看看对不对
A页面前台
<input id="Text1" type="text" value='张三'/>
<input id="Button1" type="button" value="提交" />
<script type ="text/javascript">
$( "#Button1" ).bind( "click", function ()
{
$.ajax( {
type: "post",
url: "Default.aspx",
data: "name=" + $( "#Text1" ).val(),
success: function ( result )
{
alert( result.ms );
}
} );
} );
</script>
B页面后台
protected void Page_Load(object sender, EventArgs e)
{
if (Request["name"] != null)
{
Response.ContentType = "text/json";
Response.Write("{\"ms\":\"" + Request["name"] +"wgnmd"+ "\"}");//将数据拼凑为Json
Response.End();
}
}