-1

this is my Code inside a html file:

<script>
    $(document).ready(function (event)
    {
        $(document).on("click", ".interestbutton", function(e)
        {
            var docID = e.target.parentNode.parentNode.id;
            $.ajax({
                type: "POST",
                url: "interest.php",
                data: {docID },
                success: function(data) {
                    console.log("done");
                }
                });
            });
        });
</script>

The "console.log" works but nothing inside my php file does. Any ideas?

Best regards

7
  • if console.log("done") is working then the problem must be in the php file. Could you post it? Commented May 10, 2019 at 16:45
  • for testing purposes I deleted anything except an 'echo' statement. still doesn't work! Commented May 10, 2019 at 17:34
  • Could you post it? Commented May 11, 2019 at 5:15
  • <?php echo 'inside php file'; ?> Commented May 11, 2019 at 13:42
  • And what do you get with console.log(data) in your success function? What happens when you navigate directly to interest.php? Did you double check the path to the file? Is there a .htaccess file in the directory? Commented May 11, 2019 at 19:18

1 Answer 1

0

Change data: {docID } for data: {docID: docID} as it is an object.

Sign up to request clarification or add additional context in comments.

1 Comment

thanks! But for some reason it still doesn't work. Really not sure what I'm doing wrong, other php files work without a problem for me.

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.