JavaScript - 2d Chat - Jquery?
Hello.
I'm currently playing with some projects, and one of them is creating a simple 2D chat, where users have an avatar, that they can move around and chat with. I want to do this with PHP and jQuery. Question here is, if I set it to auto-update the chat every 1 second, and get the new values in the database (if user has moved position), will it suck up too much bandwidth if there's 5 - 30 users online at the same time? I know there's other better ways of creating a 2D chat, but I'm just doing this for practice of my programming skills. Similar TutorialsSo, i have this code which retrieves php files for me using jquery and id love to get it working with Jquery history plugin. I tried modifying the code i got from the ajax demo to work for me, but i just couldnt do it as i do not know any javascript really.. ( actually what i tried was simply to change "#ajax-links a" to "#menu li a" and .html to .php ..but nothing.. :rolleyes: Id be very gratefull if someone would help me out with this one. All related code can be found bellow (the ones that should be needed anyways): This is the code that retrieves php files inside "#content" when item from "#menu li a" with the specified id is clicked Code: $(document).ready(function(){ //References var change = $("#menu li a"); var loading = $("#loading"); var content = $("#content"); //Manage click events change.click(function(){ //show the loading bar showLoading(); //load selected section if(this.id == "home") { change.load(this.className='current-page'); content.slideUp(); content.load("pages/index.php", hideLoading); content.slideDown(); } else if(this.id == "secondpage") { change.load(this.className='current-page'); content.slideUp(); content.load("pages/secondpage.php", hideLoading); content.slideDown(); } else { //hide loading bar if there is no selected section hideLoading(); } }); //show loading bar function showLoading(){ loading .css({visibility:"visible"}) .css({opacity:"1"}) .css({display:"block"}) ; } //hide loading bar function hideLoading(){ loading.fadeTo(1000, 0); }; }); Heres the structure of the menu/content Code: <ul id="menu"> <li><a id="home" class="normal" href="#Home"></a></li> <li><a id="secondpage" class="normal" href="#Secondpage"></a></li> </ul> <div id="content"> <ul id="sec-menu"> <li><a id="link1" class="normal" href="#">Link1</a></li> <li><a id="link2" class="normal" href="#">Link2</a></li> </ul> </div> Heres the code that jquery history plugin uses in demo for ajax Code: jQuery(document).ready(function($) { function load(num) { $('#content').load(num +".html"); } $.history.init(function(url) { load(url == "" ? "1" : url); }); $('#ajax-links a').live('click', function(e) { var url = $(this).attr('href'); url = url.replace(/^.*#/, ''); $.history.load(url); return false; }); }); hi, i have a jquery problem... this script is not working with jquery-1.4.2.min, but it works with jquery-1.2.6.min.js, can anyone help me???the script is the above: (it is not working the tab actions, the slideout works...) http://www.benjaminsterling.com/wp-c...es/sidetab.htm the javascript code is the above: PHP Code: var jqsideTabs; var tabs, h = 50, r = 0,ra = 0; $(document) .ready(function(){ jqsideTabs = $('#sideTabs').addClass('closed'); tabs = jqsideTabs .find('.tab h3') .clone() .appendTo(jqsideTabs) .each(function(i){ var that = $(this), cls = '',ow,newThis, newEl; if( i == 0 ) cls = ' active'; newEl = $('<a href="#" class="tabLinks'+cls+'">' + that.text() + '</a>'); that.replaceWith(newEl); ow = newEl.outerWidth(); if( i == 0 ) ra = ow; else r = ow; h = newEl.css({'top':h , 'right': -ow }).height() + h; newThis = newEl.get(0); newThis.jq = newEl; newThis.i = i; newEl.click(function(){ var el = this.jq; if( jqsideTabs.hasClass( 'closed' ) ){ jqsideTabs.removeClass('closed'); } else if( !jqsideTabs.hasClass( 'closed' ) && el.hasClass('active') ){ jqsideTabs.addClass('closed'); } el .siblings() .removeClass('active') .css({'right': -r }) .end() .addClass('active') .css({'right': -ra }); tabs.eq( this.i ).show().siblings('.tab').hide(); return false; }); }) .end() .parent() .eq(0) .addClass('active') .end() .filter(':not(:eq(0))') .hide() .end(); jqsideTabs.bind("mouseleave",function(){ jqsideTabs .animate({left:-310}, 'fast', function(){ jqsideTabs.addClass('closed').removeAttr('style'); }); }); }); and the html file is: [HTML] <div id="sideTabs"> <div class="tab"> <h3>Tab 1</h3> <div class="gut"> <p>Some text</p> </div> </div> <div class="tab"> <h3>Tab 2</h3> <div class="gut"> <ul> <li>link</li> </ul> </div> </div> <div class="tab"> <h3>Tab 3</h3> <div class="gut"> <ul> <li>link</li> </ul> </div> </div> </div> [/HTML] the problem is that the tab button works, but the content doesnt change...in all of tabs showing the same text(showing all tbas content).... can anyone help...please..... i keep getting the error GET http://code.jquery.com/jquery.min.map net::ERR_TOO_MANY_REDIRECTS & Failed to load resource: net::ERR_TOO_MANY_REDIRECTS when i load my page...and the havascript doesn't work properly on ym page...how do i resolve this. thanx in advance Hey guys. Didnt know what forum to put this in, but i figured i would put it here. Basically im making an ajax chat client. I dont know if anyone here as ever looked at googles chat client code, but if anyone knows how to make one function the same way as it, I would love if you would help me figure it out. I tried making a chat client, but it ended up being slow, buggy, and you couldnt select text because the innerhtml was refresshing so much. So how can I make a good chat client like googles? Thanks! Hey guys. I made a chat client today (my first one and it's pretty sweet so far) I have a speed problem though http://xonicgames.com/hudson/chat.php Once there are ~20+ posts it starts getting slow (at least on my connection) It does an ajax request every 500 seconds (dont know if that should be slowed down or not) What can I do to speed it up? Thanks I want to make a chat-box so people can log in under a nickname and talk to eachother, anyone have any idea how i can go about doing this?
Im not sure what type of script it is, but another site i saw had a webcam chat room that was a swf file. I know that flash, but where can i get a script for a Webcam chat room to set up on my site. Thanks What is the most efficient type of chat to make? From what I see online most people use a database and limit the number of results they return, but I noticed that some chats, like google and facebook, for some reason are able to load the full chat and get results almost instantly. How do they do it? I would love to make a replica of a google chat and just redesign the way it looks. If anyone can help me with the javascript/php part of this, that would be great. thanks! So, I need help with a script that swaps out chatango chats and allows you to expand/shrink them. Here's the source: Code: <div id="chatWrap"> <div id="cbox"></div> <div id="ccon"> <button onclick="switchChat();">Switch to <strong id="cnext">Chat Title</strong></button> <button id="csize" onclick="resizeChat();">Expand</button> </div> </div><br /> <div id="chatNotice" style="display:none;">Note: When you switch chats, the expand/shrink button stops working until you reload the page. Hopefully this will be fixed soon. <a href="javascript:void(0);" onclick="javascript:get('chatNotice').style.display='none';">[Hide this Notice]</a></div> <script type="text/javascript"><!-- // --><![CDATA[ var chats = []; chats[0] = ['Forums Chat','dh-forums-chat', 1249524788838]; chats[1] = ['Main Chat', 'dh-chat', 1247103393344]; var chat = { 'opt': 'b=60&f=50&l=999999&q=999999&r=100&s=1', 'ref': 'www.dubhappy.com', 'cur': 0, 'delay': 1.5, 'params': [['wmode','transparent'] , ['allowscriptaccess','always'] , ['allownetworking','internal']] } var chatState = 0; var chatStates = []; chatStates[0] = ['Expand', '300px']; chatStates[1] = ['Shrink', '500px']; var eles=['']; function get(id){eles[id]=eles[id]||document.getElementById(id)||false;return eles[id];} function cE(e){return document.createElement(e);} function cT(s){return document.createTextNode(s);} var ie = false; function aO(d, t, src, p, id ){ var o, e, i; if (!ie){ o = cE('object');o.data = src; } else { o = cE('embed'); o.src = src; } o.id = id; if (!ie){ p.push( ['movie', src] ); } if ( typeof(id) === 'String' ){o.id = id;} o.type = t; for(i = 0; i < p.length; i++){ e = cE('param'); e.name = p[i][0]; e.value = p[i][1]; o.appendChild(e); } d.appendChild(o); } function switchChat(){ var x = chat.cur; chat.cur = (x + 1) % chats.length; var c = chats[x]; var src = 'http://st.chatango.com/flash/group.swf?ref=' + chat.ref + '&gn=' + c[1] + '.chatango.com&cid=' + c[2] + '&' + chat.opt; get('cbox').innerHTML = ''; aO( get('cbox'), 'application/x-shockwave-flash', src, chat.params, 'chat' ); get('ccon').style.display = 'block'; // qfix get('cnext').innerHTML = chats[chat.cur][0]; get('chat').style.height = chatStates[chatState][1]; get('csize').innerHTML = chatStates[chatState][0]; } function resizeChat(){ if(chatState == 0) chatState = 1; else chatState = 0; get('chat').style.height = chatStates[chatState][1]; get('csize').innerHTML = chatStates[chatState][0]; } function chatInit(){ if (navigator.userAgent.indexOf('MSIE') !== -1){ie = true;} if ( chat.delay <= 0 ){ switchChat(); } else { var i = cE('img'); i.src = 'http://dubhappy.com/ajax-loader.gif'; get('cbox').appendChild(i); get('cbox').appendChild( cT(' Loading Chat...') ); window.clk = setTimeout( function(){switchChat(); get('chatNotice').style.display = '';}, chat.delay * 1000 ); } delete chatInit; } chatInit(); //]]></script> There's also some CSS: Code: /* Chat Styling */ #chatWrap{ width: 235px; margin: 0 auto; } #chat{ height: 300px; width: 235px; } #ccon{display: none;} #ccon a{ text-decoration: none; display: block; } This is implemented at http://forums.dubhappy.com/ As you can see by the notice under the chatbox, after swapping out the chats, the expand/shrink button no longer works until you reload the page. Do you know how to fix this? I've spent way too much time trying to figure out why this was happening. Much thanks if you manage to figure out the problem. Does anyone know of a good tutorial on how to make a good node.js chat? I need a chat that a decent VPS server can handle ~100 simultaneous users with and apparently I should be using node.js but have no experience with it. What should I look at? Thanks! Hi, I have a problem with max. memory usage, and I wonder what pingtime in a chat program is for, I imagine its to refresh to see if person is still there, but not sure, if anybody can explain. I have this on all pages where the chat is: serversession=1&pingtimes=15 I wonder if it makes any difference to change the pingtime, thanks Hello, I am very new to javascript, and I'm having a hard time finding a way to easily add some chat code to our website without manually adding it to every page. Here's the deal: I need to add this code to every page of our website: Code: <div id="cihfi9" style="z-index:100;position:absolute;"></div><div id="schfi9" style="display:inline;float:right;"></div><div id="sdhfi9" style="display:none"></div><script type="text/javascript">var sehfi9=document.createElement("script");sehfi9.type="text/javascript";var sehfi9s=(location.protocol.indexOf("https")==0?"https://secure.providesupport.com/image":"http://image.providesupport.com")+"/js/mrcuser/safe-standard.js?ps_h=hfi9\u0026ps_t="+new Date().getTime();setTimeout("sehfi9.src=sehfi9s;document.getElementById('sdhfi9').appendChild(sehfi9)",1)</script><noscript><div style="display:inline"><a href="http://www.providesupport.com?messenger=mrcuser">Live Support</a></div></noscript> I would like the chat icon to appear at the top of each page next to our main menu links. Our main menu links are called from one javascript file. I would like to figure out a way to add this code to the javascript file, so I only have to add it once. The javascript file only has one line of code: document.write(all of our main menu links). Is there a way to add the chat code to the main menu javascript file so that the chat icon will appear on every page, or is this impossible? Thanks for your help! I have developed one to one chat in asp.net. Now I wanted a gmail chat like feature in it. In left side of page, a list of online users should be available. When I click on a user, a new div should popup on right bottom corner with close and minimise buttons. When I click on another user , a second div should popup on right bottom corner of page but left to the first popup div. I want popping up of divs dynamically. The no of clicked users should decide the no of popped up divs. Also, for each division there should be a separate division ( inside the popped division ) whose innerhtml value is my chat text. And if three divs are popped up and if I close the second one, the third should get attach to first popup. Hope, you'll understand my requirements, and will provide a suitable code in javascript. Sorry if this post is very noobish, its because I am a noob. Ok, so I have a forum with Proboards and want to add a chat using the "headers/footers" but as Ive been having some trouble on my forum, I need the chat to have an admin panel (ban, warn, even see IP's if possible etc). I also need it to be streaming, not a refresh chat room. I cant seem to find a chat with this function anywhere, can anyone help? P.S I know you can have AddonChat with Proboards but that does not have the admin tools that I need and I cant afford to pay for these priveleges. If this is not possible, does anyone know any codes I could use with my AddonChat to at least give me some kind of admin control? Cheers xx I have got a script for chat room from hotscripts however the author has left the site and I am not able to contact him. So if anyone here can guide me a bit? It is basically a php/ajax chat room script using javascript. It runs fine here is a demo: Code: http://sharinganuser.freeiz.com/Test/chat/ i have set it up properly and it is even using mysql database. My question is that I want to make log of what ever the chat is happening (even the private ones) as I am admin. I am very good at php and understand what he has done in php but I when it comes to javascript i am not a person for it. So if anyone can help me with javascript? Cause when I see the msg send button source code it shows onclick is javascript:void(0) means it is using a java script. And there are total of 4 js files used: Code: http://sharinganuser.freeiz.com/Test/chat/js/ Note: log saved in database only remains for 15 minutes or somewhat like that cause i checked the data the old conversation was gone so I am now trying to use PHP fwrite code. i know how to write and implement it but again it has to go in some js file where the send button is related and I am not sure which file and exactly where. So any help would be appreciated. Regards, Hi, Im not sure if this is in the right place, but anyway, what im trying to achieve is turning an x7 chat application into a paid to chat service, i know it can be done but im just not sure how to code it, what i was wanting to do is have an earnings bar that updates itself when a member types a line of chat and credits that user with the current line pot ie 0.01 per line written on the chat (example) Users current earnings 0.0001c current written line pot 0.0003 Hope this makes sense Can anyone help me please Thanks in advance Baz var s="attr" var i=$(s) // jQuery(elem).attr(attr,eval("elm"+attr)); jQuery(elem).$(s)(attr,eval("elm"+attr));//i tried this. how to assign a variable name in the above code(in place of s) so that i need to add an attribute to the element "elem". I want to alter the script in a way where there are 2 different kinds of users that get matched up in pairs, and so that it is not entirely random. In other words, instead of just click on "Start Chat", there would be a start chat as user A, or Start chat as user B. Where by user A and B would get paired up to chat, instead of AA or BB. Here is the code for the main functions: Code: <script> var xmlHttp; var xmlHttp2; var xmlHttp3; var xmlHttp4; var xmlHttp5; var xmlHttp6; var xmlHttp7; var xmlHttp8; var xmlHttp9; var xmlHttp10; var userId = 0; var strangerId = 0; var playTitleFlag = false; // Generic function to create xmlHttpRequest for any browser // function GetXmlHttpObject() { var xmlHttp = null; try { // Firefox, Opera 8.0+, Safari xmlHttp = new XMLHttpRequest(); } catch (e) { //Internet Explorer try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } // Ajax part to get number of online chat // function getNumberOfOnlineUsers() { xmlHttp = GetXmlHttpObject(); if (xmlHttp == null) { alert("Browser does not support HTTP Request"); return; } var url = "getNumberOfUsers.php"; xmlHttp.open("POST", url, true); xmlHttp.onreadystatechange = stateChanged; xmlHttp.send(null); } function stateChanged() { if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") { var count = xmlHttp.responseText; document.getElementById("onlinecount").innerHTML = count + " users online"; window.setTimeout("getNumberOfOnlineUsers();", 2000); } } // End of get number of online users// // Ajax part start chat // function startChat() { xmlHttp2 = GetXmlHttpObject(); if (xmlHttp2 == null) { alert("Browser does not support HTTP Request"); return; } var url = "startChat.php"; xmlHttp2.open("POST", url, true); xmlHttp2.onreadystatechange = stateChanged2; xmlHttp2.send(null); } function stateChanged2() { if (xmlHttp2.readyState == 4 || xmlHttp2.readyState == "complete") { userId = trim(xmlHttp2.responseText); document.getElementById("chatbox").style.display = 'block'; document.getElementById("sendbtn").disabled = true; document.getElementById("chatmsg").disabled = true; document.getElementById("disconnectbtn").disabled = true; document.getElementById("intro").style.display = 'none'; document.getElementById("sayHi").style.display = 'none'; if (document.getElementById("chatDisconnected") != undefined) document.getElementById("chatDisconnected").style.display = 'none'; if (document.getElementById("startNew") != undefined) document.getElementById("startNew").style.display = 'none'; randomChat(); } } // End of start chat// // Ajax part leave chat // function leaveChat() { playTitleFlag = false; xmlHttp3 = GetXmlHttpObject(); if (xmlHttp3 == null) { alert("Browser does not support HTTP Request"); return; } var url = "leaveChat.php?userId=" + userId; xmlHttp3.open("POST", url, true); xmlHttp3.onreadystatechange = stateChanged3; xmlHttp3.send(null); } function stateChanged3() { } // End of leave chat// // Ajax part random chat // function randomChat() { xmlHttp4 = GetXmlHttpObject(); if (xmlHttp4 == null) { alert("Browser does not support HTTP Request"); return; } var url = "randomChat.php?userId=" + userId; xmlHttp4.open("POST", url, true); xmlHttp4.onreadystatechange = stateChanged4; xmlHttp4.send(null); } function stateChanged4() { if (xmlHttp4.readyState == 4 || xmlHttp4.readyState == "complete") { strangerId = trim(xmlHttp4.responseText); if (strangerId != "0") { document.getElementById("sendbtn").disabled = false; document.getElementById("chatmsg").disabled = false; document.getElementById("disconnectbtn").disabled = false; document.getElementById("sayHi").style.display = 'block'; document.getElementById("connecting").style.display = 'none'; document.getElementById("looking").style.display = 'none'; listenToReceive(); isTyping(); } else { window.setTimeout("randomChat();", 2000); } } } // End of random chat// // Ajax part random chat // function listenToReceive() { xmlHttp5 = GetXmlHttpObject(); if (xmlHttp5 == null) { alert("Browser does not support HTTP Request"); return; } var url = "listenToReceive.php?userId=" + userId; xmlHttp5.open("POST", url, true); xmlHttp5.onreadystatechange = stateChanged5; xmlHttp5.send(null); } function stateChanged5() { if (xmlHttp5.readyState == 4 || xmlHttp5.readyState == "complete") { var msg = xmlHttp5.responseText; if (trim(msg) == "||--noResult--||") { // other party is disconnected// document.getElementById("sendbtn").disabled = true; document.getElementById("chatmsg").disabled = true; document.getElementById("disconnectbtn").disabled = true; document.getElementById("sayHi").style.display = 'none'; document.getElementById("chatDisconnected").style.display = 'block'; document.getElementById("logbox").innerHTML += "<div id='startNew' class='logitem'><div><input value='Start New Chat' onclick='startNewChat();' type='button'></div></div>"; document.getElementById("logbox").scrollTop = document.getElementById("logbox").scrollHeight; leaveChat(); return; } else if (trim(msg) != "" && msg != undefined) { // Message received // document.getElementById("logbox").innerHTML += "<div class='logitem'><div class='strangermsg'><span class='msgsource'>Friend:</span>" + msg + "</div></div>"; document.getElementById("logbox").scrollTop = document.getElementById("logbox").scrollHeight; playTitleFlag = true; playTitle(); } window.setTimeout("listenToReceive();", 2000); } } // End of random chat// // Ajax part send chat message // function sendMsg() { var msg = document.getElementById("chatmsg").value; if (trim(msg) != "") { appendMyMessage(); xmlHttp6 = GetXmlHttpObject(); if (xmlHttp6 == null) { alert("Browser does not support HTTP Request"); return; } document.getElementById("chatmsg").value = ""; var url = "sendMsg.php?userId=" + userId + "&strangerId=" + strangerId + "&msg=" + msg; xmlHttp6.open("POST", url, true); xmlHttp6.onreadystatechange = stateChanged6; xmlHttp6.send(null); } } function stateChanged6() { } // End of send chat message// //function to append my message to the chat area// function appendMyMessage() { var msg = document.getElementById("chatmsg").value; if (trim(msg) != "") { document.getElementById("logbox").innerHTML += "<div class='logitem'><div class='youmsg'><span class='msgsource'>You:</span> " + msg + "</div></div>"; document.getElementById("logbox").scrollTop = document.getElementById("logbox").scrollHeight; } } //function to disconnect function disconnect() { var flag = confirm("Are you sure you want to disconnect?"); if (flag) { leaveChat(); document.getElementById("sendbtn").disabled = true; document.getElementById("chatmsg").disabled = true; document.getElementById("disconnectbtn").disabled = true; document.getElementById("sayHi").style.display = 'none'; document.getElementById("chatDisconnected").style.display = 'block'; } } //function to send on pressing Enter Key// function tryToSend(event) { var key = event.keyCode; if (key == "13") { sendMsg(); return; } var msg = document.getElementById("chatmsg").value; if (trim(msg) != "") { typing(); } else { stopTyping(); } } // Ajax part to indicat user is typing // function typing() { xmlHttp7 = GetXmlHttpObject(); if (xmlHttp7 == null) { alert("Browser does not support HTTP Request"); return; } var url = "typing.php?userId=" + userId; xmlHttp7.open("POST", url, true); xmlHttp7.onreadystatechange = stateChanged7; xmlHttp7.send(null); } function stateChanged7() { if (xmlHttp7.readyState == 4 || xmlHttp7.readyState == "complete") { } } // End of indicat user is typing // // Ajax part to indicat user is not typing // function stopTyping() { xmlHttp8 = GetXmlHttpObject(); if (xmlHttp8 == null) { alert("Browser does not support HTTP Request"); return; } var url = "stopTyping.php?userId=" + userId; xmlHttp8.open("POST", url, true); xmlHttp8.onreadystatechange = stateChanged8; xmlHttp8.send(null); } function stateChanged8() { if (xmlHttp8.readyState == 4 || xmlHttp8.readyState == "complete") { } } // End of indicat user is not typing // // Ajax to see if stranger is typing// function isTyping() { xmlHttp9 = GetXmlHttpObject(); if (xmlHttp9 == null) { alert("Browser does not support HTTP Request"); return; } var url = "isTyping.php?strangerId=" + strangerId; xmlHttp9.open("POST", url, true); xmlHttp9.onreadystatechange = stateChanged9; xmlHttp9.send(null); } function stateChanged9() { if (xmlHttp9.readyState == 4 || xmlHttp9.readyState == "complete") { if (trim(xmlHttp9.responseText) == "typing") { //alert("stranger is typing"); document.getElementById("typing").style.display = 'block'; } else { document.getElementById("typing").style.display = 'none'; } window.setTimeout("isTyping();", 2000); } } //Ajax to see if stranger is typing// // to start new chat // function startNewChat() { document.getElementById("logbox").innerHTML = ""; document.getElementById("logbox").innerHTML = "<div id='connecting' class='logitem'><div class='statuslog'>Connecting to server...</div></div><div id='looking' class='logitem'><div class='statuslog'>Searching for someone for you to chat with...</div></div><div id='sayHi' class='logitem'><div class='statuslog'>You're now chatting with someone new!</div></div><div id='chatDisconnected' class='logitem'><div class='statuslog'>Your partner has ended the chat.</div></div>"; startChat(); } // function to trim strings function trim(sVal) { var sTrimmed = ""; for (i = 0; i < sVal.length; i++) { if (sVal.charAt(i) != " " && sVal.charAt(i) != "\f" && sVal.charAt(i) != "\n" && sVal.charAt(i) != "\r" && sVal.charAt(i) != "\t") { sTrimmed = sTrimmed + sVal.charAt(i); } } return sTrimmed; } // function to play title // function playTitle() { document.title = "BlahTherapy"; window.setTimeout('document.title="|| BlahTherapy || ";', 1000); window.setTimeout('document.title="__ Blah Therapy __";', 2000); window.setTimeout('document.title="BlahTherapy";', 3000); if (playTitleFlag == true) { window.setTimeout('playTitle();', 4000); } } // function to detect if browser has focus window.onfocus = function() { playTitleFlag = false; } // Ajax part to save log // function saveLog() { xmlHttp10 = GetXmlHttpObject(); if (xmlHttp10 == null) { alert("Browser does not support HTTP Request"); return; } var url = "saveLog.php?userId=" + userId + "&strangerId=" + strangerId; xmlHttp10.open("POST", url, true); xmlHttp10.onreadystatechange = stateChanged10; xmlHttp10.send(null); } function stateChanged10() { if (xmlHttp10.readyState == 4 || xmlHttp10.readyState == "complete") { var log = xmlHttp10.responseText; var generator = window.open('', '', 'height=400,width=500,top=100,left=100'); generator.document.write('<html><head><title>Log File</title>'); generator.document.write('<link type="text/css" rel="stylesheet" href="files/style.css">'); generator.document.write('</head><body>'); generator.document.write(log); generator.document.write('</body></html>'); generator.document.close(); } } // End of save log// </script> Any ideas? |