嘿伙计们,对不起我糟糕的英语前锋。
我有这个代码:
<body>
<div id="left">
<p><a name = "container" value="topright" href="javascript:handleContent('topright')" onclick="loadContent('hallo1.php');">Hallo Welt 1</a></p>
<p><a name = "container" value="bottomright" href="javascript:handleContent('bottomright')" onclick="loadContent('hallo2.php');">Hallo Welt 2</a></p>
</div>
<div id="topright"></div>
<div id="bottomright"></div>
</body>
和阿贾克斯:
var xmlHttpObject = false;
if (typeof XMLHttpRequest != 'undefined')
{
xmlHttpObject = new XMLHttpRequest();
}
if (!xmlHttpObject)
{
try
{
xmlHttpObject = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
xmlHttpObject = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e)
{
xmlHttpObject = null;
}
}
}
function loadContent(id){
xmlHttpObject.open('get', id);
xmlHttpObject.onreadystatechange = handleContent;
xmlHttpObject.send(null);
return false;
}
function handleContent(){
if (xmlHttpObject.readyState == 4)
{
document.getElementById('topright').innerHTML = xmlHttpObject.responseText;
}
}
如果我单击“Hallo Welt 1”,我想在右上角的 div 中回显 Hallo1.php。因此,如果我单击“Hallo Welt 2”,我想在右下角的 div 中回显 Hallo2.php。我的 Ajax 代码中有问题。请帮助我,我是新人:)
谢谢转发