-1

Ok. I'll try to be as specific as possible.

I am creating a community website with wordpress and on it I want to establish a platform whereby one member invites another member to a specific product that they have in their inventory with an accept or reject option on the invited member's side.

So I need a kind of instant messaging script that uses a popup when one member invites the other with a DIV tag as the popup that I can put the necessary variables and images into. Once the product is accepted it will be added to the invited member's inventory and subtracted from the inventory of the member who sent the invitation.

Now, there are alot of open source IM scripts but as I am not a professional programmer, I look at it and wonder where I should begin. Could anyone point me in the right direction? How can I get started? Is there any scripts out there already like this?

Thanks in advance for your input.

Arion
  • 1
  • 2

1 Answers1

0

JAVASCRIPT (JQUERY required)

function checkmessage(){
    $.ajax({
        type: "POST",
        url: "page.php",
        data: "function=getMessages",
        success: function(msg){
            alert(msg);
            if(msg == "noMessage"){
                //do nothing
            }else{
                //should do some validation on error handling
                //then use jquery to print msg
            }
        },
        error: function(msg){
            alert('Error: cannot load page.');
        }
    });
    setTimeout("checkmessage()",3000);
}

PHP

if($_POST['function'] == "getMessages"){
    //fetch info from database
    $result = ""

    if($result){
        //echo it
    }else{
        echo "noMessage";
    }
    exit();
}

I just copy'd/edited it abit without testing so only use it as an example/guideline

This would be the most easy solution as far as i know

MakuraYami
  • 3,398
  • 3
  • 16
  • 19
  • Yeah. I know it's going to be alot of work but I at least want to try to make it happen. I figured that perhaps using some kind of jquery or javascript would do the trick but......... we'll see how it goes. Let me see what other good advice I get from this post. Thanks for your input MakuraYami :) – Arion Mar 14 '12 at 15:14
  • If you wish to go for it either way i believe there are available connections with javascript/php using sockets, else you should call a ajax function evrey 3-5 seconds to a php page that would check in the database and return a box if there is a new message. – MakuraYami Mar 14 '12 at 15:16
  • Thanks so much MakuraYami. I'm going to do some testing with what you gave me here and I'll let you know. In the meantime, I'm going to check this post off. Thanks again. – Arion Mar 14 '12 at 15:39