Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

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 = "¥¨¥éー¤Ç読¤ß込¤á¤Þ¤»¤ó¤Ç¤·¤¿";
}
});
}


Ïà¹ØÎĵµ£º

AJAXµÄjs´úÂë

 //Óû§ÃûУÑéµÄ·½·¨
//Õâ¸ö·½·¨½«Ê¹ÓÃXMLHTTPRequest¶ÔÏóÀ´½øÐÐAJAXµÄÒì²½Êý¾Ý½»»¥
var xmlhttp;
function verify() {
//0¡£Ê¹ÓÃdomµÄ·½Ê½»ñÈ¡Îı¾¿òÖеÄÖµ
//document.getElementById("userName")ÊÇdomÖлñÈ¡ÔªËØ½ÚµãµÄÒ»ÖÖ·½·¨£¬Ò»¸öÔªËØ½Úµã¶ÔÓ¦HTMLÒ³ÃæÖеÄÒ»¸ö±êÇ©£¬Èç¹û<input& ......

Óʼþ·þÎñϵͳרÌâ19£º³¬Ë¬Ajax½çÃæ

       ´ÓÖÚ¶à¿Í»§ÆÚÅÎÒѾõÄAjax½çÃæÔÚV4.0.0°æ±¾ÖнҿªÁËÃæÉ´ÒÔÀ´£¬Íز¨Èí¼þÔÚºóÐøµÄÀú´Î°æ±¾¸üÐÂÖж¼ÑÓÓò¢²»¶ÏÍêÉÆAjax½çÃæÕâ¸ö¹¦ÄÜ¡£´ó¼Ò¿ÉÒÔÏÂÔØ²âÊÔ°æ¸ÐÊÜһϣ¬»òÕߵǽTurbomailÍøÂçÔÚÏß°æÌåÑ飺
        WebÍøÖ·£ºhttp://mail.turbomail ......

AJAX (XHR)Òì²½ÇëÇóµÄһЩÈÏʶ

function sendAsynchronRequest(url,parameter,callback){
 createXMLHttpRequest();
 if(parameter == null){
  xmlHttp.onreadystatechange = callback;
  xmlHttp.open("GET",url,true);//µ±GETÇëÇóʱ£¬ÔÚµØÖ·À¸ÖÐÊÇ´ø²ÎÊýµÄ£¬¶ø²ÎÊýΪNULL£¬ËùÒÔÓÃgetÇëÇó£¬send(null)
   ......

ajaxÓëjsp »ñµÃ¿Õxml½â¾ö·½·¨


AjaxºÍjspµÄ¹ÖÏÖÏó     
Èç¹ûÓÃAjaxÈ¥ÇëÇóÒ»¸öjspÒ³Ãæ£¬¸ÃjspÒ³Ãæ·µ»ØµÄÊÇxml£¨response.setContentType("text/xml; charset=GB2312");£©£¬²¢ÇÒ¸Ãjsp°üº¬ÏÂÃæÕâЩͷ@pageÖ¸ÁîµÄ»°£¬ÔòÔÚ¿Í»§¶Ëxml=XMLHttpRequest.responseXMLµÃµ½µÄÊÇÒ»¸ö²»°üº¬ÈÎÎñ¶«Î÷µÄxml¶ÔÏ󣬼´xml.childNodes.length½«»áÊÇ0. ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ