Ajax»ñÈ¡ºǫ́Êý¾Ý
//ajax »ñÈ¡Êý¾Ý
//½Å±¾
var showResp=0;
function GetXmlHttpObject(handler)
{
var objXmlHttp = null;
if (document.all)//!window.XMLHttpRequest
{
// ´´½¨IEÖеÄXMLHttpRequest¶ÔÏó“XMLHTTP”
var clsids = ["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.5.0","Msxml2.XMLHTTP.4.0","Msxml2.XMLHTTP.3.0",
"Msxml2.XMLHTTP.2.6","Microsoft.XMLHTTP.1.0",
"Microsoft.XMLHTTP.1","Microsoft.XMLHTTP"];
for(var i=0; i<clsids.length && objXmlHttp == null; i++) {
objXmlHttp = new ActiveXObject(clsids[i]);
}
//Èç¹ûobjXmlHttp²»Îªnull£¬É趨ÆäÖ´Ðгɹ¦Ê±µÄ»Øµ÷º¯Êý¡£handler==CallbackMethod()
if (objXmlHttp != null)
{
objXmlHttp.onreadystatechange = handler;
}
}
else
{
// Mozilla | Netscape | Safari µÈÆäËüä¯ÀÀÆ÷¡£
objXmlHttp = new XMLHttpRequest();
if (objXmlHttp != null)
{
objXmlHttp.onload = handler;
objXmlHttp.onerror = handler;
}
}
return objXmlHttp;
}
var xmlHttp; //´æ·ÅÈ«¾ÖXMLHttpRequest¶ÔÏó¡£
function ExecuteCall(url,aa) //aaΪelementµÄid
{
try
{
//»ñÈ¡XMLHttpRequest²¢´æÈëxmlHttp±äÁ¿¡£
xmlHttp = GetXmlHttpObject(CallbackMethod);
//·¢ËÍÒì²½ÇëÇó¡£
xmlHttp.open('GET', url, true);
xmlHttp.send(null);
}
catch(e){}
}
//XMLHttpRequestÖ´Ðгɹ¦ºóµÄ»Øµ÷º¯Êý¡£
function CallbackMethod()
{
try
{
//ÅжÏÊÇ·ñÊdzɹ¦×´Ì¬¡£
if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
{
//È¡µÃ·µ»ØµÄ½á¹ûÊý¾Ý¡£
var response = xmlHttp.responseText;
//°Ñ·µ»ØµÄÊý¾Ý·ÅÈëÏàÓ¦HTML±êÇ©¡£
if (response.length > 0)
{
if(showResp==1)
{
document.getElementById(aa).innerHTML= response; //aaΪElementµÄID
}
}
}
}
catch(e){}
}
html ´úÂëµ÷Óà function ExecuteCall(url,aa)¡£urlΪ·þÎñÆ÷ÏòÇ°¶Ë´«ËÍÊý¾ÝµÄ ¹ý¶ÈÒ³Ã棬URL¿ÉÒÔ½øÐд«²Î¡£url ÀàÐÍ¿ÉÒÔÊÇaspx,ashx
aspxÀàÐÍ´úÂë
string str = string.Empty;
string strHtml = string.Empty;
if (Request.QueryString["id"] != null)
{
 
Ïà¹ØÎĵµ£º
ÔÚajaxû³öÀ´Ö®Ç°£¬Ò»Ö±ÊÇÓÃiframeʵÏÖµÄÎÞË¢ÐÂÇëÇó¡£
Ö÷ÒªµÄÔÀíÊÇ£º
ʹÓÃjs´´½¨Ò»¸öÒþ²ØµÄiframe
°ÑÒªÌá½»µÄ±íµ¥µÄtargetÊôÐÔÖ¸Ïò1ÖÐÉú³ÉµÄiframe
ÔÚÇëÇóµÄÒ³ÃæÖлص÷¸¸Ò³ÃæµÄ·½·¨
ÕâÑù¾ÍʵÏÖÁËÒ»¸ö¼òµ¥µÄ“Òì²½Ìá½»”
¿´ÆðÀ´ºÍajaxÒ»ÑùµÄЧ¹û£¬ÄÇΪʲô»¹ÒªÓÐajax£¬ÎÒÃÇÀ´±È½ÏÏ£º£¨ÒÔÏ°Ñajax¼¼Êõ³ÆΪX ......
Ç°ÑÔ
×î½ü³¢ÊÔÔÚGoogle App Engine£¨GAE£©Æ½Ì¨ÉϹ¹½¨Ò»¸öblog£¬Ä¿Ç°½ø¶ÈÒѾÍê³É½«½ü50%£¬ÆäÖÐCssºÍDIV²¼¾ÖÕÛÌÚµÃÎÒ¹»Çº£¬¶ÔUIÒ»ÏòÊǸöÍâÐУ¬É«¸ÐÄÃÄóʵÔÚûÆ×£¬Ö»ºÃ·ÂÔìWordpressÁË--_--||£»
ΪºÎ²ÉÓÃAJAX£º
»Ø¸´ÊÇÔÚblogÎÄÕÂÔĶÁÖеÄÒ»¸ö³£¼ûµÄ¹¦ÄÜ£¬ÈçCSDNµÄ»Ø¸´µÈµÈ£¬µ«ÊÇÒòΪ»Ø¸´ÄÚÈݲ»¶à£¬ÉõÖÁ´ó¶àÊýʱ¼äÓ ......
Ò»¡¢°×»°AjaxµÄÔÀí
Õâ¸öÆäʵҪ´ÓC/SºÍB/SµÄÔÀí˵Æð¡£Windows²Ù×÷ϵͳµÄµ®Éú£¬Îªµ¥»úͨÐÅÌṩÁ˺ܴóµÄÖ§³Ö£¬³ÌÐòÉè¼ÆÒ²´ÓDOSÔçÆڵĵ¥ÈÎÎñµ¥Óû§ÏòÍøÂçµÄ·Ö²¼Ê½Ó¦Óùý¶È¡£C/SÌṩµÄ¿Í»§/·þÎñÆ÷±à³ÌģʽΪÍøÂçÓ¦ÓÃÌṩÁËÒ»¸öÓÐЧµÄͨÐÅÊֶΡ£ä¯ÀÀÆ÷ÓëWeb·þÎñÆ÷Ö®¼äµÄÇëÇó/ ·þÎñ£¬¾ÍÊ ......
AjaxÖÐsend·½·¨²ÎÊýµÄʹÓÃ
Ò»°ãÇé¿öÏ£¬Ê¹ÓÃAjaxÌá½»µÄ²ÎÊý¶àÊÇЩ¼òµ¥µÄ×Ö·û´®£¬¿ÉÒÔÖ±½ÓʹÓÃGET·½·¨½«ÒªÌá½»µÄ²ÎÊýдµ½open·½·¨µÄurl²ÎÊýÖУ¬´Ëʱsend·½·¨µÄ²ÎÊýΪnull¡£
ÀýÈç £º
var url = "login.jsp?user=XXX&pwd=XXX";
xmlHttpRequest.open("GET",url, ......
¸Õ¿ªÊ¼Ñ§Ajax£¬¿´µ½ºÜ¶àÍøÉϵĴúÂ붼ÓÃGet·½·¨Ìá½»²ÎÊý£¬TomcatĬÈÏISO±àÂëʵÔÚÊÇÈÃÈËÍ·Í´£¬¶Ô¸¶ÂÒÂëÎÒ¶¼ÊÇÓùýÂËÆ÷×ö×Ö·û±àÂë¹ýÂ˵ģ¬Get·½·¨¹ýÂËÆ÷¼àÌý²»µ½£¬ËùÒÔÎÒһֱϲ»¶Ê¹ÓÃPost·½·¨£¬ÏÂÃæ¶ÔAjax GetºÍPost·½·¨×öÒ»¶Ô±È
GET£º
<mce:script type="text/javascript"><!--
var xmlHttpRequest;
......