0

I built this function in my html page:

<script type = "text/javascript">
    function set() {
        var type = 'test';
        var status = 0;
        var id = 2;
        $.post("sys/class/buttonHandler.php"), { status: status};
    }
</script>

that is triggered by this button:

<button type="button" onclick="set()" class="btn">Press here</button>

to reach this buttonHandler.php:

<?php

    require 'class.global.php';

    $type = 'test';
    $status = $_POST['status'];
    $id = 2;

    set($type, $status, $id);

?>

that correctly executes this function in the class.global.php:

function set($type, $status, $id)
{
    $result = mysql_query("UPDATE users SET $type = '$status' WHERE id = '$id'");
}

The problem is when I try to change the parameter that the javascript function passes or when I try to add the other two parameters, like this:

    <script type = "text/javascript">
                function set_profile() {
                    var type = 'test';
                    var status = 0;
                    var id = 2;
                    $.post("sys/class/admobButtonHandler.php"), { status: status, type: type, id: id};
                }
            </script>

<?php

require 'class.global.php';

$type = $_POST['type'];
$status = $_POST['status'];
$id = $_POST['id'];

setProfile($type, $status, $id);

?>

Nothing works anymore.. Is there any other way that I can make this work? Thanks

2
  • You are missing a ) at the end of your $.post() function, is this a mistake? Commented Mar 7, 2016 at 15:12
  • yes it was..thank you Commented Mar 7, 2016 at 15:16

1 Answer 1

1

Take a look at the jQuery docs for the post() function. http://api.jquery.com/jquery.post/. You've got your syntax all wrong... It should be:

$.post("/sys/class/admobButtonHandler.php", {status: status, type: type, id: id});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.