Jump to content
MakeWebGames

AJAX Help


Dayo

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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