dnenb Posted December 27, 2013 Share Posted December 27, 2013 I just created a chat to one of my games by following this tutorial: That dude is awesome! Check out his other tutorials. Quote Link to comment Share on other sites More sharing options...
Dayo Posted December 27, 2013 Share Posted December 27, 2013 I just created a chat to one of my games by following this tutorial: That dude is awesome! Check out his other tutorials. At the end you glossed over the delete saying you can just add this to that but someone who is watching will most likely not know how to, you are not returned the id from ajaxPost.php to use when making the new line. Would it not be best to reload the div with $('#messages').load('ajaxGet.php'); same with after deleting. Quote Link to comment Share on other sites More sharing options...
dnenb Posted December 27, 2013 Author Share Posted December 27, 2013 At the end you glossed over the delete saying you can just add this to that but someone who is watching will most likely not know how to, you are not returned the id from ajaxPost.php to use when making the new line. Would it not be best to reload the div with $('#messages').load('ajaxGet.php'); same with after deleting. Yup. As he says in the tutorial: This is a simple example :) And I learned something from it. Worth watching! Quote Link to comment Share on other sites More sharing options...
bbgengine Posted May 8, 2014 Share Posted May 8, 2014 (edited) That is a good simple little tutorial. Just make sure you go read up on sql injection before putting it on your website. // A good start to preventing sql injection (php) $post_var = mysqli_real_escape_string($_POST['var']); Also if you wanted to make it real time chat you could setup a javascript setInterval on the load function which checks for updates. http://www.w3schools.com/jsref/met_win_setinterval.asp Using some jQuery. var myVar = setInterval(function(){loadChat()}, 1000); function loadChat() { $.post('?','action=get_chat',function(d){ $('#msg').html(d); }); } I would just advice not to try to get too many users on that at one time because it would tax your website. If you want to make a larger scale chat check out socket.io with nodejs. It is more suited for real time communication browser based. There are other ways as well but this is my personal favorite. I know I did not give all the code available so feel free to ask questions and at worse I will write a tutorial when I get some time. Edited May 8, 2014 by bbgengine Quote Link to comment Share on other sites More sharing options...
sniko Posted May 9, 2014 Share Posted May 9, 2014 Also, querying the database every 1 second for every user is a little extreme. You may want to look into server-push solutions such as APE. Quote Link to comment Share on other sites More sharing options...
bbgengine Posted May 11, 2014 Share Posted May 11, 2014 Compare APE and NodeJS Socket.io both are different ways to solve the same problem. I have used APE but have come to like nodeJS socket.io better. That is just me. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.