ajaxʹÓÃPOST·½·¨Ìá½»±íµ¥
ajaxÖÐʹÓÃpost ·½Ê½Ìá½»±íµ¥Ê±ÄÜÌá½»¶à´ï2GBµÄÄÚÈÝ,¶øGET·½·¨Ö»ÄÜÌá½»×î¶à512KBµÄÄÚÈÝ.ÒÔÏÂÊÇajax POSTÌá½»µÄÀý×Ó.
<!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>Ajax POST·½·¨Ìá½»±íµ¥</title>
<script type="text/javascript">
window.onerror=function(errorMessage,errorUrl,errorNum)
{
alert(errorMessage+errorUrl+errorNum);
}
var xmlHttp;
function createXmlHttp()
{
if(window.ActiveXObject)
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
else
xmlHttp=new XMLHttpRequest();
}
function startRequest()
{
try
{
createXmlHttp();
var url="ajax_post.ashx";
var postedData=getRequestBody(document.forms["form1"]);
xmlHttp.open("post",url,true);
xmlHttp.setRequestHeader("content-length",postedData.length);//postÌá½»ÉèÖÃÏî
xmlHttp.setRequestHeader("content-type","application/x-www-form-urlencoded");//postÌá½»ÉèÖÃÏî
xmlHttp.onreadystatechange =onComplete;
&n
Ïà¹ØÎĵµ£º
AjaxºÍjspµÄ¹ÖÏÖÏó
Èç¹ûÓÃAjaxÈ¥ÇëÇóÒ»¸öjspÒ³Ã棬¸ÃjspÒ³Ãæ·µ»ØµÄÊÇxml£¨response.setContentType("text/xml; charset=GB2312");£©£¬²¢ÇÒ¸Ãjsp°üº¬ÏÂÃæÕâЩͷ@pageÖ¸ÁîµÄ»°£¬ÔòÔÚ¿Í»§¶Ëxml=XMLHttpRequest.responseXMLµÃµ½µÄÊÇÒ»¸ö²»°üº¬ÈÎÎñ¶«Î÷µÄxml¶ÔÏ󣬼´xml.childNodes.length½«»áÊÇ0.
......
±¾ÎÄÄÚÈÝÕª×Ô£º¡¶Java Web¿ª·¢½Ì³Ì——ÈëÃÅÓëÌá¸ßƪ£¨JSP+Servlet£©¡·
½»»¥µÄ»ù±¾¹ý³Ì°üÀ¨£º
l ´´½¨XMLHttpRequest¶ÔÏó£»
l ·¢ËÍÇëÇó£»
l ´¦ÀíÏìÓ¦¡£
´ ......
/*
κÑÔAJAX Àà
ʹÓ÷½·¨:
<mce:script type="text/javascript"><!--
var classAjax = new Ajax(sUrl,sRecvTyp,sQueryString,oResultFunc);
classAjax.post();//post·½Ê½·¢ËÍÊý¾Ý
classAjax.get();//get·½Ê½·¢ËÍÊý¾Ý
//sUrl·¢Ë͵ØÖ·
//sRecvTyp ½ÓÊÜÊý¾ÝÀàÐÍ:0Ϊxml 1Ϊtext
//oResultFunc ·µ»Ø½á¹û´¦Àíº ......
ajax½øÐÐÓû§µÄÓÐЧÐÔ¼ì²âʾÀý
1¡¢ ÊäÈëÓò£º
»áÔ±µÄÓÐЧÐÔ¼ì²é£º
<input type="text" name="username"> <input type="button" value="¼ì²é" onclick="return check();">
2¡¢ JavaScript½Å±¾£º
var xmlHttp;
//´´½¨XMLHttpRequest ......
ajaxµÄÁбíÁª¶¯Ê¾Àý
1¡¢ ÊäÈëÓò£º
ÇëÑ¡ÔñÊ¡£º
<select id="sel1" onchange="return choose(this);">
<option value="">--ÇëÑ¡Ôñ--</option>
<option value="1">ºþÄÏÊ¡</option>
&nb ......