Problem with jquery when use ajax on some hosting
This is code:
$.post(
aHost + '/sad_ajax.php',
{
action: "chat",
username: user,
content: content_chat
}
,
function (data) {
$("#content_chat").html(data);
}
);
it's work well on some hosting but some hoting it's doesn't work. this
is example http://changtraingheo.byethost22.com , you can use FireBug
to check it, On the server, data updated success, but it not update
content in DIV id="content_chat" . I try replace this code become
another script, it work well, this is code i changed already.
function getDataChat() {
xmlhttpPost(aHost + 'sad_ajax.php');
}
function xmlhttpPost(strURL) {
var xmlHttpReq = false;
var self = this;
// Mozilla/Safari
if (window.XMLHttpRequest) {
self.xmlHttpReq = new XMLHttpRequest();
}
// IE
else if (window.ActiveXObject) {
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
self.xmlHttpReq.open('POST', strURL, true);
self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-
www-form-urlencoded');
self.xmlHttpReq.onreadystatechange = function() {
if (self.xmlHttpReq.readyState == 4) {
updatepage(self.xmlHttpReq.responseText);
}
}
self.xmlHttpReq.send(getquerystring());
}
function getquerystring() {
var user = document.getElementById('user').value;
var content = document.getElementById('content').value;
qstr = 'action=chat&username='+escape(user)+'&content='+escape
(content) ;
return qstr;
}
function updatepage(str){
document.getElementById("content_chat").innerHTML = str;
}
Call function getDataChat first.