ajax技术带给我们的是良好的用户体验,同时,使用jquery可以简化开发,提高工作效率。
献上一个简单的例子:
前台代码:
index.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="AjaxDemo.index" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server"><title></title><script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script><script type="text/javascript" ></script>
</head>
<body><form action="" id="form_demo" method="post"><div><input type="text" name="a" value="1" id="a" /></div><div><input type="text" name="b" value="2" id="b" /></div><div><input type="hidden" name="c" value="3" id="c" /></div><div><textarea name="d" rows="8" cols="40">4</textarea></div><div><select name="e"><option value="5" selected="selected">5</option><option value="6">6</option><option value="7">7</option></select></div><div><input type="checkbox" name="f" value="8" id="f" /></div><div><input type="submit" name="g" value="Submit" id="g" /></div>
</form><script type="text/javascript" >$('#form_demo').submit(function () {$.ajax({cache: true,type: "POST",url: "test.ashx",data: $('#form_demo').serialize(),async: false,error: function (request) {alert("Connection error");},success: function (data) {alert(