Ajax 复杂数据类型使用基础
复杂数据类型使用基础
•公有属性或公有Field会被释放和接受
•容器对象
–实现IList接口的对象
–实现IDictionary接口的对象
•Key必须是String
WebService2.cs Code:
using System;
using System.Collections;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;
/// <summary>
///WebService2 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
public class WebService2 : System.Web.Services.WebService {
public WebService2 () {
//如果使用设计的组件,请取消注释以下行
//InitializeComponent();
}
[WebMethod]
public Employee HelloWorld(Employee employee) {
employee.salary = employee.salary * 2;
return employee;
}
[WebMethod]
public System.Collections.Generic.List<int> ReList(System.Collections.Generic.List<int> list)
{
list.Reverse();
return list;
}
[WebMethod]
public System.Collections.Generic.IDictionary<string, Employee> GetEmployee()
{
System.Collections.Generic.Dictionary<string, Employee> employee = new System.Collections.Generic.Dictionary<string, Employee>();
Employee employee1 = new Employee();
employee1.fristname = "churen";
employee1.lastname = "youzi";
employee1.salary = 10000;
employee[employee1.fullname] = employee1;
Employee employee2 = new Employee();
employee2.fristname = "youzi";
employee2.lastname = "churen";
employee2.salary = 20000;
employee[employee2.fullname] = employee2;
return employee;
}
}
Default4.aspx Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs" Inherits="Default4" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://ww
相关文档:
刚开始学Ajax,看到很多网上的代码都用Get方法提交参数,Tomcat默认ISO编码实在是让人头痛,对付乱码我都是用过滤器做字符编码过滤的,Get方法过滤器监听不到,所以我一直喜欢使用Post方法,下面对Ajax Get和Post方法做一对比
GET:
<mce:script type="text/javascript"><!--
var xmlHttpRequest;
......
//ajax 获取数据
//脚本
var showResp=0;
function GetXmlHttpObject(handler)
{
var objXmlHttp = null;
if (document.all)//!window.XMLHttpRequest
{
// 创建IE中的XMLHttpRequest对象“XMLHTTP”
var clsids = ["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.5.0","Msxml2.XMLHTTP.4.0","Msxml2.XMLHTTP. ......
前台:
<html>
<head>
<title>Ajax实现无刷新三联动下拉框</title>
<SCRIPT language="javascript">
......
一个简单ajax repeater分页demo 改进版. 代码如下..
<a href="javascript:void(0)" mce_href="javascript:void(0)" onclick="getData(0)">1</a>
<a href="javascript:void(0)" mce_href="javascript:void(0)" onclick="getData(1)">2< ......
Default3.aspx Code:
<%@Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>
<!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"& ......