AjaxµÄpost·½·¨µÄʹÓÃ
¸Õ¿ªÊ¼Ñ§Ajax£¬¿´µ½ºÜ¶àÍøÉϵĴúÂ붼ÓÃGet·½·¨Ìá½»²ÎÊý£¬TomcatĬÈÏISO±àÂëʵÔÚÊÇÈÃÈËÍ·Í´£¬¶Ô¸¶ÂÒÂëÎÒ¶¼ÊÇÓùýÂËÆ÷×ö×Ö·û±àÂë¹ýÂ˵ģ¬Get·½·¨¹ýÂËÆ÷¼àÌý²»µ½£¬ËùÒÔÎÒһֱϲ»¶Ê¹ÓÃPost·½·¨£¬ÏÂÃæ¶ÔAjax GetºÍPost·½·¨×öÒ»¶Ô±È
GET£º
<mce:script type="text/javascript"><!--
var xmlHttpRequest;
function createXMLHttpRequest(){
try
{
// Firefox, Opera 8.0+, Safari
xmlHttpRequest=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttpRequest=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttpRequest=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("ÄúµÄä¯ÀÀÆ÷²»Ö§³ÖAJAX£¡");
return false;
}
}
}
}
//·¢ËÍÇëÇóº¯Êý
function sendRequestPost(url,param){
createXMLHttpRequest();
xmlHttpRequest.open("GET",url+"?"+param,true);
xmlHttpRequest.onreadystatechange = processResponse;
}
//´¦Àí·µ»ØÐÅÏ¢º¯Êý
function processResponse(){
if(xmlHttpRequest.readyState == 4){
if(xmlHttpRequest.status == 200){
var res = xmlHttpRequest.responseText;
window.alert(res);
}else{
window.alert("ÇëÇóÒ³ÃæÒì³£");
}
}
}
//Éí·ÝÑéÖ¤º¯Êý
function userCheck(){
var userName = document.loginForm.username.value;
var psw = document.loginForm.password.value;
if(userName == ""){
window.alert("Óû§Ãû²»ÄÜΪ¿Õ");
document.loginForm.username.focus();
return false;
}
else{
Ïà¹ØÎĵµ£º
½ñÌìÎÒѧϰÁËÙ¡ÀÏʦ½²µÄajaxµÄ֪ʶ£º
Ò»¡¢ Ajax
a) ÔÊÐíä¯ÀÀÆ÷Óë·þÎñÆ÷ͨÐŶøÎÞÐëˢе±Ç°Ò³ÃæµÄ¼¼Êõ¶¼±»½Ð×öAjax¡£Êý¾ÝÔÚ¿Í»§¶ËÓë·þÎñÆ÷Ö®¼ä¶ÀÁ¢´«Êä¡£·þÎñÆ÷²»ÔÙ·µ»ØÕû¸öÒ³Ãæ
b) XMLHttpRequest£º¸Ã¶ÔÏ ......
ºÜ¾ÃÒÔÇ°£¬ÎÒѧ»áÁËÓÃdhtmlxtree£¬ÄÇÊÇÒ»¿ÃºÜ²»´íµÄÊ÷£¬ÓÃÆðÀ´ºÜ·½±ã£¬µ«ÊÇÒ»¸öÎÊÌâһֱûÓнâ¾ö£¬´ÓÇ°¶¼ÊǷֺܶà´ÎÈ¥Êý¾Ý¿âÖв飬×ñѵÄÔÔòÊÇ£¬ÏȲé³öÉϼ¶£¬È»ºóÔÙ¸ù¾ÝÉϼ¶ID²é³öϼ¶ID£¬ÕâÑùÒ»²ãÒ»²ãµÄ²é£¬ÓÚÊǵ±Êý¾ÝÁ¿´óÁË£¬Ê÷¼ÓÔصÄʱºò»áºÜµÄºÜÂý£¬ÓÐʱºòµÈËû¿ªÊ¼¼ÓÔصÄʱºò£¬¿ÉÒÔ¸æËßÆÁÄ»Ç ......
Ò»¡¢°×»°AjaxµÄÔÀí
Õâ¸öÆäʵҪ´ÓC/SºÍB/SµÄÔÀí˵Æð¡£Windows²Ù×÷ϵͳµÄµ®Éú£¬Îªµ¥»úͨÐÅÌṩÁ˺ܴóµÄÖ§³Ö£¬³ÌÐòÉè¼ÆÒ²´ÓDOSÔçÆڵĵ¥ÈÎÎñµ¥Óû§ÏòÍøÂçµÄ·Ö²¼Ê½Ó¦Óùý¶È¡£C/SÌṩµÄ¿Í»§/·þÎñÆ÷±à³ÌģʽΪÍøÂçÓ¦ÓÃÌṩÁËÒ»¸öÓÐЧµÄͨÐÅÊֶΡ£ä¯ÀÀÆ÷ÓëWeb·þÎñÆ÷Ö®¼äµÄÇëÇó/ ·þÎñ£¬¾ÍÊ ......
ÔÚ×î½ü¿ªÊ¼½«AJAX¼¼Êõ¼ÓÈëµ½ÈÕ³£µÄ¿ª·¢¹¤×÷ÖС£ÎÒÔÚ×î½üдÁ˸öAJAXµÄÎÞˢеǽÇÒ¶¯Ì¬Ìí¼Ó·þÎñÆ÷¿Ø¼þµÄ¹¤×÷£¬ÎÒ½«´Ë¹¦ÄܸæËß´ó¼ÒÏ£Íû¶Ô´ó¼ÒµÄ¹¤×÷ÓÐËù°ïÖú¡£Èç¹û´ó¼ÒÓиüºÃµÄ·½·¨ÇÒÔ¸ÒâÔÚ´ËÁôÑÔÈÃÎÒÒ²¿ÉÒÔ·ÖÏíµ½ÄãµÄ³É¹û¡£
Ê×ÏÈÔÚÒ³ÃæÖеÄHTML±ê¼ÇÖмÓÈë¿Ø¼þUpdatePanelºÍÁ½¸öTextboxÒ»¸öButton£º
<asp:UpdatePanel ID ......
AjaxÖÐsend·½·¨²ÎÊýµÄʹÓÃ
Ò»°ãÇé¿öÏ£¬Ê¹ÓÃAjaxÌá½»µÄ²ÎÊý¶àÊÇЩ¼òµ¥µÄ×Ö·û´®£¬¿ÉÒÔÖ±½ÓʹÓÃGET·½·¨½«ÒªÌá½»µÄ²ÎÊýдµ½open·½·¨µÄurl²ÎÊýÖУ¬´Ëʱsend·½·¨µÄ²ÎÊýΪnull¡£
ÀýÈç £º
var url = "login.jsp?user=XXX&pwd=XXX";
xmlHttpRequest.open("GET",url, ......