/* 异步获取文字的五笔简码和拼音简码，
    getSpellAndWBCode(string strName) 生成汉字拼音码的函数，参数：汉字    
*/

//得到拼音简及五笔简码；
function getSpellAndWBCode(str, serverPageURL) {
    //showCustomer("../common/SpellCode.aspx", str);

    var result = str;

    xmlHttp = getXmlHttpObject();
    if (xmlHttp == null) {
        alert("Your browser does not support AJAX!");
        return;
    }

    var url = serverPageURL;  //../common/SpellCode.aspx
    url = url + "?text=" + escape(str);
    url = url + "&sid=" + Math.random();
    xmlHttp.onreadystatechange = function () {
        result = xmlHttp.responseText;  //拼音码|五笔码
    };
    xmlHttp.open("GET", url, true);
    xmlHttp.send(null);

    return result;
}

function getXmlHttpObject() {
    var xmlHttp = null;
    try {
        // Firefox, Opera 8.0+, Safari
        xmlHttp = new XMLHttpRequest();
    }
    catch (e) {
        // Internet Explorer
        try {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp;
}

/**********服务端页面后台代码示例
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace demo
{
    public partial class SpellCode : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["text"] != null)
            {
                string text = Request.QueryString["text"];
                VA.Utils.SpellAndWbCode spell = new VA.Utils.SpellAndWbCode();

                string code = spell.GetSpellCode(text) + "|" + spell.GetWBCode(text);
                Response.Write(code);
                Response.End();
            }
        }
    }
}
*****/