Reputation: 21
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?
Upvotes: 0
Views: 3548
Reputation: 1122
And you can use
<?php $variable = $_REQUEST['name']; ?>
if not shure how it should be get.
Upvotes: 0
Reputation: 235
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.
Upvotes: 1
Reputation: 20859
The variable values are not included in $_GET
you might find them in $_POST
<?php $variable = $_POST["name"]; ?>
Upvotes: 5