ajax ¶ÁÈ¡ .csv Îļþ
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>JavaScript Sample</title>
<link rel="stylesheet" type="text/css" href="main.css" media="all">
<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript" src="main.js"></script>
</head>
<body>
<h1>CSVÐÎʽ¤Î¥Çー¥¿¤ò読¤ß込¤ß±íʾ¤¹¤ë</h1>
<div id="tableData">¥Çー¥¿¤ò読¤ß込¤ßÖÐ....</div>
</body>
</html>
window.onload = function(){
var msec = (new Date()).getTime();
new Ajax.Request("data.csv", {
method: "get",
parameters: "cache="+msec,
onSuccess:function(httpObj){
var text = httpObj.responseText;
var LF = String.fromCharCode(10);
var tabText = text.split(LF);
var tbl = "<table border='1'>";
for (var i=0; i<tabText.length; i++){
var cText = tabText[i].split(",");
tbl += "<tr>";
for (var j=0; j<cText.length; j++){
tbl += "<td>"+cText[j]+"</td>";
}
tbl +="</tr>";
}
tbl += "</table>";
$("tableData").innerHTML = tbl;
},
onFailure:function(httpObj){
$("tableData").innerHTML = "¥¨¥éー¤Ç読¤ß込¤á¤Þ¤»¤ó¤Ç¤·¤¿";
}
});
}
Ïà¹ØÎĵµ£º
20 ¸ö¾µäµÄ Ajax + CSS ±í¸ñ
²¢²»ÊÇËùÓеÄWeb ¿ª·¢Õß¶¼»á¶ÔÃÀ»¯±í¸ñÊý¾Ý¸ÐÐËȤ£¬½ñÌìÎÒÃÇÊÕ¼¯ÁË20 ¸ö¹¦ÄÜÇ¿´ó£¬Íâ¹ÛƯÁÁµÄ»ùÓÚAjax + CSS µÄ±í¸ñЧ¹û£¬Äã¿ÉÒÔ´ÓÕâЩʾÀýÖÐѧϰÔõôʹÓÃÕâЩ±í¸ñÌṩµÄÅÅÐòºÍ¹ýÂ˵ŦÄÜÀ´×éÖ¯±í¸ñÖеÄÊý¾Ý¡£
ÏÖÔÚÈÃÎÒÃÇÀ´¿´¿´ÕâЩ±í¸ñ£º£¨µã»÷ÿ¸öÑùÊ½Ç°ÃæµÄÁ´½Ó¼´¿É½øÈëÏÂÔØ£©
¡¡¡¡#1. ......
<script language="javascript" type="text/javascript">
var xmlHttp = null;
function CreateXMLHttp()
{
......
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£©¡·
ÏÂÃæÒÔ×¢²á¹ý³ÌÖÐÓû§ÃûÊÇ·ñ´æÔÚµÄÑé֤ΪÀý½éÉÜAJAXµÄÓ¦Óá£
¹¦ÄÜÃèÊö£ºÓû§×¢²áµÄÓû§Ãû²»ÔÊÐíÖØ¸´£¬ËùÒÔÔÚÓû§ÌύʱºòÐèÒªÅжϡ£ÎªÁËÈÃÓû§ÔçÖªµÀ½á¹û£¬ÔÚÓû§ÊäÈëÓû§ÃûÖ®ºó¾ÍÓ¦¸Ã½øÐÐÅжϣ¬¿ÉÒÔ²ÉÓÃAJAX½øÐд¦Àí¡£
¼ÙÉ裺ΪÁ˼ò»¯´ú ......
±¾ÎÄÄÚÈÝÕª×Ô£º¡¶Java Web¿ª·¢½Ì³Ì——ÈëÃÅÓëÌá¸ßƪ£¨JSP+Servlet£©¡·
½»»¥µÄ»ù±¾¹ý³Ì°üÀ¨£º
l ´´½¨XMLHttpRequest¶ÔÏó£»
l ·¢ËÍÇëÇó£»
l ´¦ÀíÏìÓ¦¡£
´ ......