我用下面的Ajax代碼加載HTML頁面:jQuery的不是我的Ajax的支持
var AJAX = {
request:false,
createHttpRequest:function()
{
//initiate HttpRequest for AJAX calling
if (!AJAX.request && typeof XMLHttpRequest!='undefined')
{
try
{
AJAX.request = new XMLHttpRequest();
}
catch (e)
{
AJAX.request=false;
alert("This Browser Does not Support AJAX");
}
}
if (!AJAX.request && window.createRequest)
{
try
{
AJAX.request = window.createRequest();
}
catch (e)
{
AJAX.request=false;
alert("This Browser Does not Support AJAX");
}
}
},
call:function(method,url,asyn)
{
AJAX.request.open(method,url,asyn);
},
send:function(value)
{
AJAX.request.send(value);
}
}
var serverTable;
var popup;
var NAVIGATION = {
MENU:function(filename,table,ftpFlag,ftppath,svrpath)
{
AJAX.createHttpRequest();
AJAX.call("GET",filename,true);
AJAX.request.onreadystatechange=function()
{
if (AJAX.request.readyState==4)
{
document.getElementById('contentMain').innerHTML=AJAX.request.responseText;
if(ftpFlag==true)
{
document.getElementById("conStatus").src="images/spinner.gif";
$('#serverFileTree').fileTree(
{
root: svrpath, script: 'serverfileTree.php'
},
function(file)
{
alert(file);
});
$('#ftpFileTree').fileTree(
{
root: ftppath, script: 'ftpfileTree.php'
},
function(file)
{
alert(file);
});
popup= $("#destname").dialog(
{
resizable: false,
height:180,
modal: true,
title: "Destination File Name",
draggable: true,
autoOpen: false,
hide:true,
buttons:
{
Ok: function()
{
if(document.getElementById('destfiletext').value.match(" "))
{
alert("There should be no space in name");
}
else
{
destDirSelected=destDirSelected+document.getElementById('destfiletext').value;
serverTable.fnAddData([destDirSelected,selected]);
AJAX.createHttpRequest();
AJAX.call("GET","prepareFtpReplace.php?src="+selected+"&dest="+destDirSelected,true);
AJAX.request.onreadystatechange=function()
{
if (AJAX.request.readyState==4)
{
}
}
AJAX.send(null);
$(this).dialog('close');
}
},
Cancel: function()
{
$(this).dialog('close');
}
}
});
}
if(table==true)
{
serverTable = $("#serverList").dataTable(
{
"bPaginate": false,
"bFilter": false,
"bSort": false,
"bInfo": false,
});
}
}
}
AJAX.send(null);
}
}
與此代碼的html頁面戰平「contentMain」股利。
這裏是我的主HTML:
<body bgcolor="#828282">
<table width="967px" height="400px" align=center cellpadding="0" cellspacing="0">
<tr>
<td colspan="3" height="80px" class="ui-widget-shadow" align="center">
<span style="font-family:verdana;font-size: 26px;font-weight: bold; text-align: center;color:#fff" ></span>
<span style="text-align: right; float:right;" ><img height="55px" width="55px" src="images/m1.jpg" /></span>
</td>
</tr>
<tr>
<td colspan="3" height="25px" align="center">
<span style="float:right;">Welcome Mr. <?php echo $u; ?>| <a href="logout.php">logout</a></span>
</td>
</tr>
<tr>
<td colspan="3" height="2px" bgcolor="#828282" align="center">
</td>
</tr>
<tr>
<td width="180px" valign="top" align="center" height="100%" >
<?php include("tiles/leftMenu.php");?>
</td>
<td width="5" bgcolor="#828282">
</td>
<td align="center" valign="top">
<div id="contentMain"></div>
</td>
</tr>
</table>
</body>
問題是當我在「contentMain」分區然後是包含在加載的html頁面不能正常使用jQuery的加載HTML頁面。我怎麼解決這個問題?提前致謝。
ummm爲什麼不使用** ANY **的jQuery的ajax方法,如果您使用的是jQuery? – Neal 2011-05-05 20:54:11
@Neal在我現有的代碼中是否有解決方案? – 2011-05-05 20:57:58