asp.net中添加数据ajax读取不到新数据,请高手指教
--插入数据方法
function insertUser()
{
$.get("inseruser.ashx",{uname:$("#uname").val(),upwd:$("#upwd").val(),uage:$("#uage").val(),usex:$("#usex").val()},function(msg){
$("#aaa").text(msg);
getdata3();
});
}
---得到所有信息方法
function getdata3()
{
$.getJSON(
"UserAllHandler.ashx",
function(data){
var table=$("<table align=center width=60% border=1>"+
"<tr>"+
"<td>编号</td>"+
"<td>姓名</td>"+
"<td>年龄</td>"+
"<td>密码</td>"+
"</tr></table>");
var user=data;
//document.write(user.length);
for(var i=0;i<user.length-1;i++)
{
$("table").empty();
u=user[i];
var row=$("<tr></tr>");
//document.write(key);
var td0=$("<td></td>");
td0.text(i+1);
var td1=$("<td></td>");
td1.text(u.uname);
var td2=$("<td></td>");
td2.text(u.upwd);
var td3=$("<td></td>");
td3.text(u.uage);
td0.appendTo(row);
td1.appendTo(row);
td2.appendTo(row);
td3.appendTo(row);
row.appendTo(table);
}
table.appendTo($("#dd"));
},"json");
}
------------UserAllHandler.ashx文件
<%@ WebHandler Language="C#" Class="UserAllHandler" %>
using System;
using System.Web;
using System.Data;
using System.Text;
public class UserAllHandler : IHttpHandler {
Users user = new Users();
DataSet ds = new DataSet();
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
//context.Response.Write("Hello World");
context.Response.Clear();
this.ds = user.userSelectAll();