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

×î¼òµ¥µÄAjaxÈëÃÅÀý³Ì

<?php
if(isset($_GET['do']) && $_GET['do']==='ajax')
{
exit("{msg:'Hello World!'}");
}
?>
<!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 Demo</title>
<script type="text/javascript">
function readyStateChangeHandle(xhr)
{
// ¾ßÌå²Ù×÷,ÐèÒªÁ˽âÒ»ÏÂJavaScriptµÄÏà¹Ø֪ʶ
eval('var result='+xhr.responseText);
window.alert(result.msg);
}
function Ajax()
{
// ´´½¨Òì²½ÇëÇó¶ÔÏó
var xhr=window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
// ÅжÏһ϶ÔÏóÊÇ·ñ´´½¨³É¹¦
if(!xhr)
{
return false;
}
// ÉèÖÃÒì²½ÇëÇó´¦Àíº¯Êý(ÕâÀïÓÃÄäÃûº¯Êý¶ø²»Ö±½ÓÓö¨ÒåºÃµÄº¯Êý,Ö÷ÒªÊÇ·½±ã´«µÝ²ÎÊý)
xhr.onreadystatechange=function(){
// readyStateÓÐ4ÖÖ״̬(0=UNINITIALIZED,1=LOADING,2=LOADED,3=INTERACTIVE,4=COMPLETED)
if(xhr.readyState==4)
{
// statusʵ¼ÊÉϾÍÊÇHTTP״̬Âë
if(xhr.status==200)
{
readyStateChangeHandle(xhr);
}
}
};
xhr.open("GET","ajax.php?do=ajax",true);
xhr.send(null);
}
</script>
</head>
<body>
<button type="button" onclick="Ajax();">Ajax</button>
</body>
</html>


Ïà¹ØÎĵµ£º

AJAXʵʱ¶ÁÈ¡ÊäÈëÎı¾

 ¿Í»§¶ËString.php,·þÎñÆ÷¶ËString_check.php£¬ºÜ¼òµ¥µÄʵÏÖ¡£
¿Í»§¶Ë´úÂ룺
<!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="Conten ......

AJAXÀà

 AJAXÀà
// AJAXÀà
function AJAXRequest() {
var xmlObj = false;
var CBfunc,ObjSelf;
ObjSelf=this;
try { xmlObj=new XMLHttpRequest; }
catch(e) {
try { xmlObj=new ActiveXObject("MSXML2.XMLHTTP"); }
catch(e2) {
try { xmlObj=new ActiveXObject("Microsoft.XMLHTTP"); }
catch(e ......

XMLHttpRequest Ajax ʵÀý¼ò½é

Ò»¡¢XMLHttpRequest ¶ÔÏóµÄ·½·¨ÓëÊôÐÔ
·½    ·¨
Ãè    Êö
abort()
Í£Ö¹µ±Ç°ÇëÇó
getAllResponseHeaders()
°ÑHTTPÇëÇóµÄËùÓÐÏìÓ¦Êײ¿×÷Ϊ¼ü/Öµ¶Ô·µ»Ø
getResponseHeader("header")
·µ»ØÖ¸¶¨Êײ¿µÄ´®Öµ
open("method", "url")
½¨Á¢¶Ô·þÎñÆ÷µÄµ÷Óá£method²ÎÊý¿ÉÒÔÊÇGET¡¢POST»òPUT¡£ ......

php ajax debug method make log in a text file

log into file
//
ob_start();
echo "<pre>";
print_r($data);
echo "</pre>";
$a=ob_get_contents();
//DAL::remove("insert into mytest(vvv) values('$a')");
$filename = "file.txt";
$file = fopen($filename, "w") ......

ajaxÂÒÂë½â¾ö×ܽá


javascriptÑØÓÃjavaµÄ×Ö·û´¦Àí·½Ê½£¬ÄÚ²¿ÊÇʹÓÃunicodeÀ´´¦ÀíËùÓÐ×Ö·ûµÄ£¬
µÚ¶þ£¬utf-8ÊÇÿ¸öºº×Ö£¨unicode×Ö·û£©ÓÃ3¸ö×Ö½ÚÀ´´æ´¢¡£
µÚÈý£¬ÓÃutf-8À´sendÊý¾ÝÊDz»»á³öÏÖÂÒÂëµÄ£¬ÊǺǫ́³ÌÐòûÓÐÕýÈ·½âÂë²Å»á³öÏÖÂÒÂë¡£
µÚËÄ£¬ajax·¢ËÍÊý¾ÝµÄʱºòÈç¹ûÐÞ¸Ä Content-Type Ϊ application/x-www-form-urlencoded"£¬¿Ï¶ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ