Ajax 客户端代理的作用
客户端代理的作用
在对象里做了一个标记
–“__type” = “ComplexType.Color”
服务器端根据标记选择反序列化的目标类型
可出现“多态”效果
Employee.cs Code:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
/// <summary>
///Employee 的摘要说明
/// </summary>
public abstract class Employee
{
public Employee()
{
//
//TODO: 在此处添加构造函数逻辑
//
}
private string _fristname;
public string Fristname
{
get { return _fristname; }
set { _fristname = value; }
}
private string _lastname;
public string Lastname
{
get { return _lastname; }
set { _lastname = value; }
}
private int _year;
public int Year
{
get { return _year; }
set { _year = value; }
}
public abstract int Salary();
}
public class Sxs : Employee
{
public override int Salary()
{
return 2000;
}
}
public class Djl : Employee
{
public override int Salary()
{
return 2000 + 100*(Year +3);
}
}
public class Zsz : Employee
{
public override int Salary()
{
return 2000 + 100*(Year + 1);
}
}
WebService.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>
///WebService 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
public class WebService : System.Web.Services.WebService {
public WebService () {
//如果使用设计的组件,请取消注释以下行
//InitializeComponent();
}
[WebMethod]
[
相关文档:
Ajax中send方法参数的使用
一般情况下,使用Ajax提交的参数多是些简单的字符串,可以直接使用GET方法将要提交的参数写到open方法的url参数中,此时send方法的参数为null。
例如 :
var url = "login.jsp?user=XXX&pwd=XXX";
xmlHttpRequest.open("GET",url, ......
Html代码:
<%@ page language="java" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>jquery ajax</title>
<link rel="stylesheet" type="text/css" media="screen"
......
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!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=" ......
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
/// <summary>
/// Summary description for Commen ......
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"& ......