客户端用一个html页面调用一个ashx文件(一般http处理程序),返回 json格式的自定义对象:

html:--------------------------------------------------

<!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>
    <title>ajax测试</title>

    <script src="js/jquery-1.2.3.js" type="text/javascript"></script><!-这里引用了jQuery框架->
</head>
<body>
<script type="text/javascript">
$(document).ready(function(){
           $("#Button2").click(function(){
           var url="handler.ashx?&name="+$("#Text1").val()+"&age="+$("#Text2").val();
           $.get(url,function(result){
           var obj=eval("("+result+")");
                                alert("姓名:"+obj.Name+"\n"+"年龄:"+obj.Age);
                           })
                        })
})
</script>
    <input + Age;
        }
       
        public person(string name,string age)//自定义类person
        {
            this.Name = name;
            this.Age = age;
        }
        public person()
        { }
    }
}

相关文章:

  • 2021-08-15
  • 2021-06-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-14
  • 2021-11-22
猜你喜欢
  • 2021-08-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-03
  • 2022-01-02
相关资源
相似解决方案