100·Ö£¡ajaxÇëÇó´íÎó
C# code:
<script type="text/javascript">
window.onload=function()
{
startRequest('get','../College.ashx','lxyc=2&time='+new Date().getTime()+'',ShowIt,true);
}
var xmlHttp1;
function createXMLRequest()
{
if(window.ActiveXObject)
{
xmlHttp1=new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest)
{
xmlHttp1=new XMLHttpRequest();
}
else
{
alert("²»ÄÜ´´½¨XMLHttpRequest");
}
}
function startRequest(method,url,pars,callbackfun,cache)
{
// alert(method+url+pars+callbackfun+cache);
if(typeof callbackfun != 'function'){
alert('The CallBackFun is not a function!');
}
if(cache){
pars += "&tmp="+Math.random();
}
createXMLRequest();
xmlHttp1.onreadystatechange = function(){
if(xmlHttp1.readyState==4)
{
if(xmlHttp1.status==200)
{
callbackfun(xmlHttp1);
xmlHttp1.abort();
}
else
{
xmlHttp1.abort();
Ïà¹ØÎÊ´ð£º
֮ǰÓöµ½Ò»¸öÎÊÌâ¡£
ÓÚÊÇ×öÁËÒÔÏÂʵÑ飺
Ò³Ãæ¼ÓÔØºó£¬Ìá½»Ò»¸öAjaxÇëÇó(ÔݳÆÎªajax1)£¬ÇëÇóµÄÏß³ÌÔÚ·þÎñÆ÷Éϱ»Ë¯Ãß10ÃëÖÓ¡£
µã»÷Ò³ÃæÉÏÒ»¸öbutton£¬´¥·¢ÁíÒ»¸öAjaxÇëÇó(ajax2)¡£
µ±Ã»ÓÐʹÓÃsession£¬ÔÚ·þÎñÆ÷δ´ ......
ÎÒÔÚwebRoot££¾idc££¾report££¾report_add.jspÒ³ÃæÖÐÓÃajaxÌá½»µ½action×ÜÊDZ¨Õâ´í
140 ERROR RequestProcessor:664 - Invalid path /idc/report/report/report_distb was requested
ÕÒ²»³öÔÒò,ÎÒÓÖÔÚн¨ ......
function checkCallBack(){
if(xmlHttp.readyState==4){
if(xmlHttp.status==200){
var result = xmlHttp.responseText;
......
Ò»htmlÒ³ÃæÊý¾ÝÈçÏ£º
<ul>
<li>aaa </li>
<li>bbb </li>
<li>ccc </li>
</ul>
ͨ¹ýJQµÄajax·½·¨Ö®ºó£¬µÃµ½µÄ¾¹È»±ä³ÉÁË£º
......
»Øµ÷º¯ÊýÈçÏ£º
function deleteCallBack(data)
{
if(data=="ɾ³ý³É¹¦")
{
alert(data);
location.reload();
}
else
{
alert(data);
}
}
²»Ìø×ª Ö»ÊÇÏÔʾalertÐÅÏ ......