AjaxʹÓÃʾÀý
/***************************by
garcon1986********************************/
Index.php:
<script type="text/javascript" src="ajax.js" ></script>
<a href="#" onclick="funphp('S')" >S</a>
<a href="for.php?url=E" >E</a>
<div id="idiv"></div>
for.php:
<?php
error_reporting(E_ALL ^ E_NOTICE);
if($url = $_GET[url]){
for($i=1;$i<10;$i++){
echo $url;
}
exit();
}
?>
Ajax.js:
//Ê×ÏÈÉùÃ÷±äÁ¿
var xmlHttp;
//´´½¨¶ÔÏóº¯Êý
function GetXmlHttpObject(){
try{
//Firefox, Opera, Safari
xmlHttp = new XMLHttpRequest();
}
catch(e){
try{
//MS IE 6.0+
xmlHttp = new ActiveXObject(Msxml2.XMLHTTP);
}
catch(e){
try{
//MS IS 5.5+
xmlHttp = new ActiveXObject(Microsoft.XMLHTTP);
}
catch(e){
alert("ÄúµÄä¯ÀÀÆ÷²»Ö§³ÖAJAX£¡");
return false;
}
}
}
}
//·¢ËÍÇëÇóº¯Êý
function funphp(t){
//µ÷ÓÃGetXmlHttpObjectº¯Êý
GetXmlHttpObject();
//open() ·½·¨ÐèÒªÈý¸ö²ÎÊý¡£µÚÒ»¸ö²ÎÊý¶¨Òå·¢ËÍÇëÇóËùʹÓõķ½·¨£¨GET »¹ÊÇ POST£©¡£µÚ¶þ¸ö²ÎÊý¹æ¶¨·þÎñÆ÷¶Ë½Å±¾µÄ
URL¡£µÚÈý¸ö·½·¨¹æ¶¨Ó¦µ±¶ÔÇëÇó½øÐÐÒì²½µØ´¦Àí¡£
xmlHttp.open("GET","for.php?url="+t, true);
//Ö¸¶¨ÏìÓ¦º¯Êý
xmlHttp.onreadystatechange = effect;
//·¢ËÍÇëÇó¡£µ±Ê¹ÓÃGET·½·¨Ê±£¬Ò»°ãsendÀïµÄ²ÎÊýÊÇnull¡£Èç¹ûÊÇPOST»áÓÐËù²»Í¬¡£
xmlHttp.send(null);
}
//´¦Àí·µ»ØÐÅÏ¢º¯Êý
function effect(){
if(xmlHttp.readyState == 4){
if(xmlHttp.status == 200){
var cao = xmlHttp.responseText;
document.getElementById('idiv').innerHTML = cao;
}
}
}
×¢ÊÍ£º
xmlHttpRequest.readyStateµÄ5ÖÖ״̬£º
0 (Uninitialized)
The object has been created, but not initialized (the open method has
not been called).
1 (Open)
The object has been created, but the send method has not been called.
2 (Sent)
The send method has been called. responseText is not available.
responseBody is not available.
3 (Receiving)
Some data has been received. responseText is not available. responseBody
is not available.
Ïà¹ØÎĵµ£º
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0044)http://www.qqip.cn -->
<HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>new document</TITLE>
<META ht ......
µÚ 1 ²¿·Ö: Ajax ¼ò½é
Ajax ÓÉ HTML¡¢JavaScript¡¢DHTML ºÍ DOM ×é³É£¬ÕâÒ»½Ü³öµÄ·½·¨¿ÉÒÔ½«±¿×¾µÄ Web ½çÃæת»¯³É½»»¥Ð﵀ Ajax Ó¦ÓóÌÐò¡£±¾ÎĵÄ×÷ÕßÊÇһλ Ajax ר¼Ò£¬ËûÑÝʾÁËÕâЩ¼¼ÊõÈçºÎÐͬ¹¤× ......
Ê×ÏÈÔÚfademo.mxmlÖÐÉùÃ÷Ò»¸öbutton£¬²¢Ìí¼ÓÒ»¸öbtnClick·½·¨£º
view plaincopy to clipboardprint?
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
......
±¾ÎĵØÖ·: jQuery Ajax È«½âÎö
±¾ÎÄ×÷ÕߣºQLeelulu
תÔØÇë±êÃ÷³ö´¦£¡
jQueryȷʵÊÇÒ»¸öͦºÃµÄÇáÁ¿¼¶µÄJS¿ò¼Ü£¬ÄÜ°ïÖúÎÒÃÇ¿ìËٵĿª·¢JSÓ¦Ó㬲¢ÔÚÒ»¶¨³Ì¶ÈÉϸıäÁËÎÒÃÇдJavaScript´úÂëµÄÏ°¹ß¡£
·Ï»°ÉÙ˵£¬Ö±½Ó½øÈëÕýÌ⣬ÎÒÃÇÏÈÀ´¿´Ò»Ð©¼òµ¥µÄ·½·¨£¬ÕâЩ·½·¨¶¼ÊǶÔjQuery.ajax()½øÐзâ×°ÒÔ·½±ãÎÒÃÇʹÓõķ½·¨£¬µ±È»£¬È ......
ÔÚÒ»¸öÏîÄ¿Öзּ¶Ñ¡ÔñÐÐÕþÇø»®Ê±Óõ½AJAX½øÐÐÎÞˢм¶Áª£¬ÎÒÔÚÒ³ÃæÖбàÂëÓõÄÊÇUTF-8£¬×ÜÊDZ¨½Å±¾´íÎó£¬
ÎÒ°ÑÒ³Ãæ±àÂë»»³ÉGBKÓÖÊÇÕý³£µÄ£¬ºóÀ´ÔÚÍøÉÏËÑË÷ÁËһϣ¬ÔÚÒýÈëJSʱ¼ÓÈë±àÂë¾Í¿ÉÒÔÁË£¬ÈçÏ£º
<script language="Javascript" src="js/jquery.js" charset="gb2312"></script> ......