Question

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.

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top