My only problem right now that seems to be giving me trouble is relaying the data the PHP recieves back to AJAX so it than can append the data to my chat box.
Here is what I have for my request...
Code: Select all
function connect()
{
var page = getXHRObject();
page.onreadystatechange = function()
{
if (page.readyState == 3 && page.status == 200)
parse(page.responseText);
}
page.open("GET", "botmain.php", true);
page.send();
}
Code: Select all
function addChat(msg_type, icon, text)
{
var msgtype_pln;
var icon_str;
if (msg_type === undefined) msg_type = 0;
if (icon === undefined) icon = 0;
if (msg_type == 0)
msgtype_pln = 'ui-state-highlight';
else
msgtype_pln = 'ui-state-error';
switch (icon)
{
case 0:
icon_str = '';
break;
case 1:
icon_str = 'class="ui-icon ui-icon-info" ';
break;
case 2:
icon_str = 'class="ui-icon ui-icon-person" ';
break;
case 3:
icon_str = 'class="ui-icon ui-icon-alert" ';
break;
case 4:
icon_str = 'class="ui-icon ui-icon-notice" ';
break;
}
$('.bot_chat').append('<div class="' + msgtype_pln + ' ui-corner-all" style="margin-top: 1px; padding: 0 .7em;"><p><span ' + icon_str + 'style="float: left; margin-right: .3em;"></span>' + text + '</p> </div>');
$('.bot_chat').scrollTop($('.bot_chat')[0].scrollHeight);
}
"Connecting..."
"Connecting...
Connected!"
"Connecting...
Connected!
Sending login information..."
An so on. Is there a better way to communicate to AJAX with PHP without using the XMLHttpRequest object?
Thanks in advanced!