PHP+AjaxʵÏÖTabЧ¹û
ÓÃAjaxʵÏÖTabЧ¹ûµÄ
ÏÈ´´½¨
ajax.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>
<title>Sample 2_1</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
<!--
//Create a boolean variable to check for a valid Internet Explorer instance.
var xmlhttp = false;
//Check if we are using IE.
function creatXMLHttp(){
try
{
//If the Javascript version is greater than 5.
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
//alert ("You are using Microsoft Internet Explorer.");
}
catch (e)
{
//If not, then use the older active x object.
try
{
//If we are using Internet Explorer.
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
//alert ("You are using Microsoft Internet Explorer");
}
catch (E)
{
//Else we must be using a non-IE browser.
xmlhttp = false;
}
}
//If we are using a non-IE browser, create a javascript instance of the object.
if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
{
xmlhttp = new XMLHttpRequest();
//alert ("You are not using Microsoft Internet Explorer");
}
}
function makerequest(serverPage, objID)
{
creatXMLHttp();
var obj = document.getElementById(objID);
xmlhttp.open("GET", serverPage);
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
obj.innerHTML = xmlhttp.responseText;
}
}
xmlhttp.send(null);
Ïà¹ØÎĵµ£º
$_SERVER['PHP_SELF'] #µ±Ç°ÕýÔÚÖ´Ðнű¾µÄÎļþÃû£¬Óëdocument rootÏà¹Ø¡£
$_SERVER['argv'] #´«µÝ¸ø¸Ã½Å±¾µÄ²ÎÊý
$_SERVER['argc'] #°üº¬´«µÝ¸ø³ÌÐòµÄÃüÁîÐвÎÊýµÄ¸öÊý£¨Èç¹ûÔËÐÐÔÚÃüÁîÐÐģʽ£©¡£
$_SERVER['GATEWAY_INTERFACE'] #·þÎñÆ÷ʹÓÃµÄ CGI ¹æ·¶µÄ°æ±¾¡£ÀýÈ磬& ......
½ñÌì¸ÕѧÍêmysqli£¬È¥ÎÒµÄIDCÔËÓªÉÌÄÇ¿´ÁËһϣ¬·¢ÏÖËûÃǵÄÐéÄâÖ÷»ú¾ÓÈ»²»Ö§³Ö£¬ÎÒÓÖÈ¥ÆäËû¼¸¼Ò¿´ÁË¿´£¬ÓеÄÖ§³ÖÓеIJ»Ö§³Ö¡£
ÎÒ¾ÍÏë×Ô¼ºÐ´¸öÀ࣬ÈÃËûÈ¥Åжϣ¬ÄÜÓÃmysqli¾ÍÓÃmysqli£¬·ñÔò¾ÍÓÃÔʼµÄmysqlº¯Êý¡£²»¹ýÎÊÌâÂíÉϾÍÀ´ÁË£¬×Ô¼ºÐ´Àà»á²»»áµ¼ÖÂÖ´ÐÐЧÂʱäµÍÁËÄØ£¿ÓÚÊÇÎҾͽøÐÐÁËÈçϲâÊÔ¡£
ÕâÊÇÓÃÀ´¼ÆʱµÄÀࣺ
/* ......
//calendar.php
<?¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
/*******************************¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
¡¡*¡¡ ÓÃÀ´ÅжÏÊÇ·ñÈòÄêµÄº¯Êý¡¡¡¡*¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
¡¡*¡¡ ¿ÉÒÔ¸ù¾Ý¸ü¸´ÔÓµÄËã·¨¸Ä½ø¡¡*¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ ......
1£©·¢ËÍ·¾¶ÖеIJÎÊýÓÐÖÐÎÄ£¬ÔÚ·þÎñÆ÷¶Ë½ÓÊÕ²ÎÊýÖµÊÇÂÒÂë
½â¾ö·½·¨£º
PHP:
·þÎñÆ÷¶Ë£ºiconv("UTF-8","gb2312",$_POST[±äÁ¿Ãû]);
JSP:
¿Í»§¶Ë:
ÀûÓÃjavascriptµÄÌṩµÄescape()»òencodeURI()·½·¨, Àý
var url="a.jsp?name=СÀî"£»
url=encodeURI(url);
url=encodeURI(url); //Á½´Î£¬ºÜ¹Ø¼ü[¾ßÌåΪʲô£¬ÎÒÒ²²»Çå³þ ......