【发布时间】:2014-04-25 15:53:39
【问题描述】:
我在 PHP 页面中进行了 Ajax 聊天,一切都运行良好且流畅。 然后我尝试在弹出的 div 中的另一个页面上采用此聊天(通过 z-index 上的 css)。
这是代码:
function showChat(username){
var
$http,
$self = arguments.callee;
if (window.XMLHttpRequest) {
$http = new XMLHttpRequest();
} else if (window.ActiveXObject) {
try {
$http = new ActiveXObject('Msxml2.XMLHTTP');
} catch(e) {
$http = new ActiveXObject('Microsoft.XMLHTTP');
}
}
if ($http) {
$http.onreadystatechange = function()
{
if (/4|^complete$/.test($http.readyState)) {
window.parent.document.getElementById('chatbox').style.display = "block";
window.parent.document.getElementById('chatbox').innerHTML = $http.responseText;
}
};
$http.open('GET', "dashchat/chatbox.php?chatWith="+username, true);
$http.send(null);
}
}
div 显示,聊天的文本框显示,但消息不显示 ajax 没有运行,当我提交消息时它重定向到我的 sendmessage.php 有什么想法吗?
【问题讨论】:
-
你得到了什么回应?
-
我正在获取我的 php 页面,但 ajax 没有运行
-
但是如果我去那个聊天页面本身就可以正常工作
标签: javascript php jquery ajax