0

I have a small problem to get jQuery post variables. So i have javascript file where is code bellow:

<script type="text/javascript">
$.post("view.php", { name: "John" } );
</script>

And i try to get that name "John" in view.php file like this:

<?php $variable = $_GET["name"]; ?>

And it wont get that name. Can someone please help me?

1
  • 2
    try $_POST["name"] instead... Commented Feb 20, 2012 at 6:21

4 Answers 4

5

The variable values are not included in $_GET you might find them in $_POST

<?php $variable = $_POST["name"]; ?>
Sign up to request clarification or add additional context in comments.

Comments

1

Since you've used '$.post' you must use the related action which will be $_POST. If you were using '$.get', then you would use your current method of $_GET.

Comments

0

Use $_POST instead of $_GET...

Comments

0

And you can use

<?php $variable = $_REQUEST['name']; ?>

if not shure how it should be get.

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.