I'm trying to set a confirmation box to delete a message using javascript/jquery on a php page. The variables are being set correctly in the javascript function, but now I can't get the function to properly post to the page.
I have the following included in the head
<script src="http://code.jquery.com/jquery-latest.js"></script>
Now for the code.
//displays a list of messages w/ button to delete 
if(mysql_real_escape_string($_GET['msg'] == "msgDetail")){
            $msg->messageDetail($msgID);
            $action = "delete";
            $msgID = mysql_real_escape_string($_GET['msgID']);
            //display a delete button that sends variables to javascript function
            echo '<td>'.'<input type="button" value="Delete Message" name = "deleteMessage" onclick="deleteMessage(\'' . $msgID .'\', \'' .$action. '\',\'' .$userid. '\')" />'.'</td>';
        }
        ?>
        //javascript function for confirmation to delete message
        <script type="text/javascript">
        function deleteMessage(msgID, action, userid){
            //document.write(msgID + action + userid) values are correctly showing up here when uncommented
                if (!confirm("Are you sure?"))
                    return false;
                $.post('messages.php',"msgID=" + msgID + "&action=" + action + "&user=" + userid, function(response) {
                    //window.location.reload()
                });
        }
        </script>
    <?
      //check to see if the values have been posted
    if($_POST['action']) == "delete"){
        echo "success!";
             ....more code
    }
As you can see, I'm trying to post the variables to messages.php but when I check if even one is posted, nothing happens.
mysql_real_escape_stringis for input, no point calling it on output, you'll need to call it again within messages.php before you insert anyway.messages.php? if so you won't see thesuccess!echo unless you're looking in the response from your ajax call with something like firebug.