Jump to content
MakeWebGames

Recommended Posts

Posted

Hiya is it possable to show an element once a table in the DB has been altered ie user 1 clicks send and user2 automaticly gets a popup saying you have a new meaasage!

Posted

From what I have read, it would be best to use txt file or some other sort of file rather then a sql DB for something like this. I may be wrong though.

Posted

Him.

Ofcourse you could do upon member1 sending the mail to member2, check whether member2 is online (surely you have some form of last action field) then work out a way to send a pop-up to that member, right now I cannot actually think but Google may be useful for this.

Posted

Checking a DB is fine... if the DB is small, the best choice is to use a MySQL memory table if possible, however keep in mind memory tables do not keep the data after a reboot and backups don't store the data neither. So it must be like just a pure "cache" or "notify" area.

Using text files is also ok, but then keep the file very small.

Posted

The pm thing was just an example what I really wanted was to show when user 1 is online and user 2 logsin it says user 2 is online.

I said upon SQL update as I can do a simple query in the user database to find any person who has logged in within x amount of seconds and is a friend of the user

I'm trying to make my game more social rather then the constant click click click

Posted

Thanks rulerofzu I'll try it when I get home I did do he 30mins of googling before posting but didn't really know what to search for as I very dearly use Ajax and normally that is a premade script :)

Posted

XMLHttpRequest will work for FF and Chrome but not for IE if I remember right... I can send you a snippet how to do it if you need to or other option is to use JQuery for such things.

Other option is to use an IFRAME and refresh it. You can either make it directly visible such that you show stuff there or you make it invisible and use JS to grab the content from within the IFRAME.

Posted

That's the base JS code I use

 

function ajaxCall(url)
{
   var http = null;

   try
   {
       http = new XMLHttpRequest();
   }
   catch (e)
   {
       try
       {
           http = new ActiveXObject("Microsoft.XMLHTTP");
       }
       catch (e2)
       {
           http = false;
       }
   }
   if (!http)
   {
       return false;
   }

   http.open("GET", url);
   http.onreadystatechange = function()
   {   
       if (http.readyState == 4)
       {   
	// Do something with http.responseText
       }
   }

   http.send(null);
   return false;
}

 

call the function function with the URL you want, and in the "// do something" area parse the text or use it...

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.   Paste as plain text instead

  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...