ajax ·µ»Øjson
µ±ÓÃajax·µ»Ø¶à¸öÖµµÄʱºò£¬¿ÉÒÔÓÃxml£¬Ò²¿ÉÒÔÓÃjson
jsonʵÀý
<html>
<head>
<title>AjaxTest</title>
<script type="text/javascript">
var xmlHttp;
function createXMLHttpRequest()
{
if(window.ActiveXObject)
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest)
{
xmlHttp = new XMLHttpRequest();
}
}
function startRequest()
{
createXMLHttpRequest();
try
{
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.open("GET", "Json.txt", true);
xmlHttp.send(null);
}
catch(exception)
{
alert("xmlHttp Fail");
}
}
function handleStateChange()
{
if(xmlHttp.readyState == 4)
{
if (xmlHttp.status == 200 || xmlHttp.status == 0)
{
var result = xmlHttp.responseText;
var json = eval("(" + result + ")");
&nb
Ïà¹ØÎĵµ£º
ʹÓÃAjaxÖвéѯÊý¾Ý¿âʱ£¬Ö»µÚÒ»´Î²éѯÁËÊý¾Ý¿â£¬ÒÔºóÔÙÓÐÇëÇó¾Í²»Ìá½»¸ø·þÎñÆ÷´¦ÀíÁË
ҳͷµÄÇ建´æ±êǩûÆð×÷ÓÃ
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
½â¾ö·½·¨£º
1£º¼Óʱ¼ä´Á var url ......
ÔÚ¿´ÎÄÕÂÇ°£¬ÏÈÖ¸¶¨Ò»¸öͨÓõıäÁ¿xhr£¬xhr´úÂëajax¶ÔÏó¡£
²âÊÔä¯ÀÀÆ÷£ºieΪie6£¬firefoxΪ2£¬ÆäËûµÄδ²âÊÔ¡£Í³³Æie6Ϊie£¬firefox2Ϊff¡£
»ù±¾µÄ
1£¬×î¾µäµÄ¾ÍÊÇieϵĻº´æÎÊÌâÁË¡£
Èç¹ûʹÓõÄÊÇget£¬ÄÇôÔÚieϳöÏÖ»º´æÎÊÌâ¡£µ¼Ö´úÂëÖ»Ö´ÐÐÒ»´Î¡£½â¾ö°ì·¨¾ÍÊǼÓʱ¼ä´Á»òÕßËæ»úÊý£¬Ê¹url±äΪΨһ£¬ÕâÑù¾Í²»»á³öÏÖ ......
±¾ÎÄÄÚÈÝÕª×Ô£º¡¶Java Web¿ª·¢½Ì³Ì——ÈëÃÅÓëÌá¸ßƪ£¨JSP+Servlet£©¡·
½»»¥µÄ»ù±¾¹ý³Ì°üÀ¨£º
l ´´½¨XMLHttpRequest¶ÔÏó£»
l ·¢ËÍÇëÇó£»
l ´¦ÀíÏìÓ¦¡£
´ ......
ÔÚʹÓÃJQueryµÄajax·ÃÎÊÒ³Ãæʱ£¬×ÜÊdzö´í£¬µÃ²»µ½·µ»ØµÄhtml´úÂ룬ÓÖ²»ÖªµÀ³öµÄʲô´í£¬°Ù˼²»µÃÆä½â
ÓÚÊǾÍÓÃXMLHTTPÈ¥·ÃÎÊ£¬½á¹ûÒ²³ö´í£¬²»¹ýÄܹ»µÃµ½´íÎóÔÒò£¬È»ºó¸ù¾Ý´íÎóÒòΪȥÍøÉϲ飬ÖÕÓڵõ½Á˴𰸡£¡£
ÔÀ´jspµÄ±àÂëÓëjavaµÄ±àÂë²»Ò»ÖÂ
·½°¸¢Ù
´íÎó
<%@ page contentType="text/html;charset= ......