Hello,
I got this script that I coded up last night but for some reason whenever i passed stuff into the function, it comes up as 'undefined' I've had issues like this before but can't remember how i solved it the XMLHttpRequest object works but it relies on these inputs to perform the correct commands back to my PHP file that sends back the requested data.
So example of how I'm passing the commands in:
getAjax('getallmessages','inline_chat_win');
the first command will be used to pass to the php file and the second is the DIV element to be used in:
$(''+ div +'').html(httpReq.responseText).fadeIn(1000);
But neither get the correct input as both just get undefined? This has baffled me as I've tried doing many things to solve it.... here's my function below:
and heres the code block that sends in the input:Code:function getAjax(cmd,frame) { var httpReq; try{ // Firefox, Opera 8.0+, Safari httpReq = new XMLHttpRequest(); } catch (e) { try{ // Microsoft Internet Explorer (ActiveX) httpReq = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ // Again with Microsoft => Boring! httpReq = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { // Oh dear their browser doesn't support this? This is very rare! alert("Your browser seems to not support the XMLHttpRequest object? Please consider upgrading your browser."); return false; } } } httpReq.onreadystatechange = function() { // Remember to also set 200 for the status if( httpReq.readyState == 4 && httpReq.status == 200 ) { $('#'+ frame +'').html(httpReq.responseText).fadeIn(1000); } } var command = cmd; httpReq.open("GET","inline_chat.php?cmd_="+ command,true); httpReq.send(null); } window.onload = function() { setInterval("getAjax()",10000); }
Code:window.onload = function() { $("#loading").remove(); getAjax('getallmsgs','inline_win_chat'); // Gets all messages from the server }



Reply With Quote
that did the trick i feel really stupid for making that mistake, again was tired when i did that part. But thanks again!!!

Bookmarks