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.
Ïà¹ØÎĵµ£º
ÏîÄ¿ÖÐÏëÓÃajax
£¬ÓÚÊÇÔÚÍøÉÏ°ÇÁË
n
¶à×ÊÁÏ£¬·¸ÁË
n
¶à´íÎ󣬴ӽñÌìÉϰൽÏÖÔÚÒ»Ö±ÔÚ´¦ÀíÕâ¸öÎÊÌ⣬ÖÕÓÚ»¹ÊÇ°ÑËü½â¾öÁË¡£
µ±ÎÒ¿´µ½Ò³ÃæµÄajax
ÏÔʾºó£¬ÎÒÐË·ÜÒì³££¬ÎªÁ˼Ǽ×Ô¼ºÑ§Ï°µÄ
ajax
Àú³Ì£¬Ò²ÎªÁËÈøü¶àµÄÈËÉÙ×ßÍä·£¬ÌØд´ËÒ»ÎÄÒÔ¼ÇÖ®£¡
·Ï»°²»ËµÁË£¬ÎªÁ˸üºÃµÄÀí½â£¬ÎÒÖØ×öÁËÒ»¸öСµÄÏî ......
ajax.dllÒѾÊǺÜÀϵĶ«Î÷ÁË£¬µ«ÊǽñÌìÎÒ²ÅÓõ½Ëü£¬ÏÖÔÚ°ÑËüµÄʹÓ÷½·¨¼Ç¼ÏÂÀ´¡£
1.ÔÚweb.configÖÐÅäÖÃajaxµÄ´¦Àí³ÌÐò¡£
<httpHandlers>
<add verb="POST,GET" path="ajax/*.ashx" type="Ajax.PageHandlerFactory, Ajax" />
<httpHandlers>
2. ×¢²á´¦Àí³ÌÐòÀ࣬ajaxTestÊ ......
ÔÚÍøÉÏÏÂÁËIngelliJ9.0£¬°²×°Íê³Éºó£¬ÆȲ»¼°´ýµÄ´ò¿ª£¬È´Ìáʾ“The JVM could not be started. The main method may have thrown an exception.” ÓÖÈ¥ÍøÉÏÕÒÁËÕÒ£¬½â¾öµÄ°ì·¨ÊÇ°ÑbinĿ¼ÏµÄidea.exe.vmoptions ÎļþÓÐд×Ö°å´ò¿ª£¬°ÑÀïÃæµÄÄÚÈݸÃΪ-Xms32m
-Xmx512m
-XX:MaxPermSize=120m
-ea
......
×î½üµÄÏîÄ¿ÀïÓõ½AjaxControlToolkit 3.5,ÏîÄ¿Íê³ÉÒÔºóÔÚ±¾µØ²âÊÔûÎÊÌ⣬·Åµ½·þÎñÆ÷ÉÏÈ¥ÔÚIE6¾Í³öÏÖAjax ¿Í»§¶Ë¿ò¼ÜδÄܼÓÔصÄÎÊÌ⣬ÔÚFF£¬IE7£¬Opera£¬SafariµÈä¯ÀÀÆ÷¶¼Ã»ÎÊÌ⣬ÕæÊǸ㲻¶®MSÔõô¸ãµÃ£¬ÏÖÔÚ ¾ÍÏëÅ×ÆúIE6£¬ÕҵĺÃÐÁ¿à°¡£¬ÍøÉÏ˵µÄ½â¾ö·½°¸¶¼ÊÔ¹ýÁË£¬¶¼Ã»Óã¬×îºóÕÒµ½µÄ´ð°¸ÊÇ£ºÓ¦ÓóÌÐòµÄ±àÂëÎÊ Ì⣬ֻҪÔÚ ......
µÚËÄÕ Ajax·þÎñÆ÷À©Õ¹ÆÊÎö
Ajax·þÎñÆ÷À©Õ¹£ºASP.NET Ajax¿ò¼ÜµÄ·þÎñÆ÷¶Ë¡£
4.1ASP.NET ¿ª·¢ÈËÔ±µÄAjax
Ϊ·þÎñÆ÷¶Ë¿ª·¢ÌṩAjaxÖ§³Ö¡£°üÀ¨Ò»×éеķþÎñÆ÷¿Ø¼þºÍ·þÎñ£¬ÓÃÀ´ÃþÄâ¿Í»§¶ËAjaxÐÐΪ¡£
4.2¸Ä½øÔÓÐASP.NETÍøÕ¾
(1)¸ÄÉÆÍøÂçÑÓ³Ù£º¾¡×î´ó¿ÉÄܼõÉÙä¯ÀÀÆ÷ºÍ·þÎñÆ÷Ö®¼ä´«µÝµÄÊý¾ÝÁ¿¡£
(2)Ïû³ýȫҳà ......