ÍêÃÀAjaxÀà,Ö§³Öʼþ
<scrīpt Language="Javascrīpt">
<!--
// author:±¼ÌÚµÄÐÄ
// qq:7180001
function Ajax(OnError,OnState,OnDownloadEnd)
{
this.ErrorStr = null;
this.OnError = OnError;
this.OnState = OnState;
this.OnDownloadEnd = OnDownloadEnd;
this.method = "GET";
this.URL = null;
this.sync = true;
this.PostData = null
this.RetData = null;
this.HttpObj = this.createXMLHttpRequest();
if(this.HttpObj == null)
{
return;
}
var ōbj = this;
this.HttpObj.onreadystatechange = function()
{
Ajax.handleStateChange(Obj);
}
}
Ajax.prototype.UTFTOGB = function(strBody)
{
var Rec=new ActiveXObject("ADODB.RecordSet");
Rec.Fields.Append("DDD",201,1);
Rec.Open();
Rec.AddNew();
Rec(0).AppendChunk
Ïà¹ØÎĵµ£º
upload.jsp
<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP ''upload.jsp'' starting page</title>
&n ......
¡¡Ò»°ãÇé¿öÏ£¬Ê¹ÓÃAjaxÌá½»µÄ²ÎÊý¶àÊÇЩ¼òµ¥µÄ×Ö·û´®£¬¿ÉÒÔÖ±½ÓʹÓÃGET·½·¨½«ÒªÌá½»µÄ²ÎÊýдµ½open·½·¨µÄurl²ÎÊýÖУ¬´Ëʱsend·½·¨µÄ²ÎÊýΪnull¡£
ÀýÈç £º
¡¡¡¡ var url = "login.jsp?user=XXX&pwd=XXX";
¡¡¡¡xmlHttpRequest.open("GET",url,true);
¡¡¡¡xmlHttpRequset.send(null);
¡¡¡¡´ËÍ⣠......
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Ajaxµ¯³öʾÀý-¿É¿ ......
Ä¿µÄ£ºÍ¨¹ýÒ»¸öỊ̈߳¬ÅжÏSESSIONÊÇ·ñ¹ýÆÚ£¬Èç¹û¹ýÆÚ£¬µ÷Óÿͻ§¶ËÒ³ÃæµÄJS£¬°ÑÐÅÏ¢ÍÆ¸ø¿Í»§¶Ë¡£
ÎÒÃÇÒªÈÃDWR³ÌÐòÖ§³Ö·´ÏòAJAX¡£ÐèÒªÔÚweb.xmlÖÐDWRServletÀïÌí¼ÓÒ»¸ö³õʼ»¯²ÎÊý£¬ÁíÍâÒªÅäÖÃÒ»¸ö¼àÌýÆ÷£¬ÔÚÊʺϵÄʱºò¹Ø±ÕÏ̡߳£
ÈçÏÂÊÇweb.xmlÖеÄÅäÖÃ
<listener>
< ......
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<input type="button" onclick="test();" value="Ìá½»"/>
<script type="text/javascript">
function test(){
var valid = {
& ......