Jump to content

Recommended Posts

Hi.

 

My question is as follows: How does one go about making a program that when two players are logged onto the site and maybe there is a condition (like both have a $_GET['id'] number being the same), and one does something, it reloads the other's page.

 

An example of this to clear it up is a chat program where when you type something and click enter, everyones chat reloads.

I'm not asking for any extensive answers (though It'd be nice ;) ), just a few words on what scripting language this is done in and what I should search for to learn it.

 

Thanks a bunch!

Link to comment
https://forums.phpfreaks.com/topic/154881-solved-dont-know-if-this-is-javascript/
Share on other sites

I read something about using ajax/php that doesn't continually check the db for changes and only triggers an event if it is changed (to keep down on server load). I know some ajax, but no java/flash so I'd prefer that method.

The main UI would be clicking on something and having it appear as an image on the main page for both users.

good call, didn't think that through enough then, did I?

 

Do any of you know if I could use jQuery to do this checking? I know how to use it to check the script page (just use .load()) but if there is a quick way to attach that to a timer event instead of a keyboard/click/mouse action... If there isn't a quick way, I'll try and find the harder one myself

thanks again

Well, hell, there was a tutorial in Better Software magazine from a few years ago that I read which is exactly what you need. It was an AJAX tutorial using a chat application as the example. It was title "The Many Layers of AJAX". I still have that issue on my bookcase, unfortunately I can't find the article available online - unless you bug a subscription to stickyminds.com to see the archives.

 

But, the basic premise is that you would use AJAX to send/recieve the data from the Client and Server. The clinet would simply have a timed event to check the server to see if there are any updates (i.e. posts by other users) and a client invoked even (onclick) to send updates from the user.

 

So setInterval has been working right how I want it to, so thanks for that.

 

I was just wondering if there is a reason this doesn't work in IE:

 

<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script language="javascript" type="text/javascript">
var int=self.setInterval("clock()",1000)
function clock()
  {
  
  $('.checky').load('load.php?id='+'<?php echo $row['id']?>');
  }
</script>

 

For firefox it runs load.php every second, while in IE it runs it once then stops.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.