Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

js Ajax Àà Éú»îÒª¿ìÀÖ

/*
κÑÔAJAX Àà
ʹÓ÷½·¨:
<mce:script type="text/javascript"><!--
var classAjax = new Ajax(sUrl,sRecvTyp,sQueryString,oResultFunc);
classAjax.post();//post·½Ê½·¢ËÍÊý¾Ý
classAjax.get();//get·½Ê½·¢ËÍÊý¾Ý
//sUrl·¢Ë͵ØÖ·
//sRecvTyp ½ÓÊÜÊý¾ÝÀàÐÍ:0Ϊxml 1Ϊtext
//oResultFunc ·µ»Ø½á¹û´¦Àíº¯Êý
// --></mce:script>
Ó¦ÓÃʵÀý£º
<mce:script type="text/javascript"><!--
var ajax1 = new Ajax("1.asp",0,"id="+id,bacal);
ajax1.post();
function bacal(rexm){
//·µ»ØÊý¾Ý´¦Àíº¯Êý;
}
// --></mce:script>
*/
function Ajax(sUrl,sRecvTyp,sQueryString,oResultFunc) {
this.Url = sUrl;
this.QueryString = sQueryString;
this.XmlHttp = this.createXMLHttpRequest();
if (this.XmlHttp == null) {
alert("erro");
return;
}
var objxml = this.XmlHttp;
objxml.onreadystatechange = function (){Ajax.handleStateChange(objxml,sRecvTyp,oResultFunc)};
}
Ajax.prototype.createXMLHttpRequest = function() {
try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {}
try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {}
try { return new XMLHttpRequest(); } catch(e) {}
return null;
}
Ajax.prototype.createQueryString = function () {
var queryString = this.QueryString;
return queryString;
}
Ajax.prototype.get = function () {
sUrl = this.Url;
var queryString = sUrl+"?timeStamp=" + new Date().getTime() + "&" + this.createQueryString();
this.XmlHttp.open("GET",queryString,true);
this.XmlHttp.send(null);
}
Ajax.prototype.post = function() {
sUrl = this.Url;
var sUrl = sUrl + "?timeStamp=" + new Date().getTime();
var queryString = this.createQueryString();
this.XmlHttp.open("POST",sUrl,true);
this.XmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
this.XmlHttp.send(queryString);
}
Ajax.handleStateChange = function (XmlHttp,sRecvTyp,oResultFunc) {
if (XmlHttp.readyState == 4) {
if (XmlHttp.status == 200) {
oResultFunc(sRecvTyp?XmlHttp.responseXML:XmlHttp.responseText);
} else {
alert("ÄúËùÇ


Ïà¹ØÎĵµ£º

AjaxÌá½»´óÊý¾Ý£ºFormÓëQuery

      AjaxÌá½»Êý¾ÝÒ»°ã¶¼ÊÇͨ¹ýURLºó±ßµÄ²ÎÊýÐÎʽÀ´´«µÝÊý¾ÝµÄ£¬±ÈÈçʹÓÃXMLHttpRequest.open('POST', url, true);µÄ·½Ê½Ê¹ÓÃʱ£¬Æäurl²ÎÊýÖоͰüº¬ÁËÐèÒªÌá½»µÄÊý¾Ý£¬ËüµÄÐÎʽÈ磺http://www.mysite.com/handler.do?name='²Ü²Ù'&sex='ÄÐ'£¬ÊÇ°Ñkey=valueÐÎʽµÄÊý¾Ýͨ¹ý &·ûºÅÁ¬½ÓÆðÀ´£¬ ......

AjaxÑéÖ¤Óû§ÃûÊÇ·ñ´æÔÚ

<script language="javascript" type="text/javascript">
        var xmlHttp = null;
        function CreateXMLHttp()
        {
           ......

Ajax¶¨Ê±Ë¢ÐÂÒ³Ãæ

var xmlHttp;
var flag = false;
function createXMLHttpRequest()
{
  if(window.ActiveXObject)
  {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  else if(window.XMLHttpRequest)
  {
  xmlHttp=new XMLHttpRequest();
  }
}
fu ......

ajaxÓëjsp »ñµÃ¿Õxml½â¾ö·½·¨


AjaxºÍjspµÄ¹ÖÏÖÏó     
Èç¹ûÓÃAjaxÈ¥ÇëÇóÒ»¸öjspÒ³Ã棬¸ÃjspÒ³Ãæ·µ»ØµÄÊÇxml£¨response.setContentType("text/xml; charset=GB2312");£©£¬²¢ÇÒ¸Ãjsp°üº¬ÏÂÃæÕâЩͷ@pageÖ¸ÁîµÄ»°£¬ÔòÔÚ¿Í»§¶Ëxml=XMLHttpRequest.responseXMLµÃµ½µÄÊÇÒ»¸ö²»°üº¬ÈÎÎñ¶«Î÷µÄxml¶ÔÏ󣬼´xml.childNodes.length½«»áÊÇ0. ......

ajax ϵͳ´íÎó 1072896748

ÔÚʹÓÃJQueryµÄajax·ÃÎÊÒ³Ãæʱ£¬×ÜÊdzö´í£¬µÃ²»µ½·µ»ØµÄhtml´úÂ룬ÓÖ²»ÖªµÀ³öµÄʲô´í£¬°Ù˼²»µÃÆä½â
ÓÚÊǾÍÓÃXMLHTTPÈ¥·ÃÎÊ£¬½á¹ûÒ²³ö´í£¬²»¹ýÄܹ»µÃµ½´íÎóÔ­Òò£¬È»ºó¸ù¾Ý´íÎóÒòΪȥÍøÉϲ飬ÖÕÓڵõ½Á˴𰸡£¡£
Ô­À´jspµÄ±àÂëÓëjavaµÄ±àÂë²»Ò»ÖÂ
·½°¸¢Ù
 ´íÎó
<%@ page contentType="text/html;charset= ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ