Reputation: 59
$.get ("php/checkuser.php", {username : "stackexchange"}, function(data){
console.log(data)
});
How do I retrieve/handle the "username" in the PHP file? as far as I can tell it isn't stored in a variable and there is no further documentation on the relevant jQuery website.
I am clearly lacking some simple knowledge here.
Upvotes: 1
Views: 43
Reputation: 1378
The jQuery get() method is used to send a HTTP GET request.
So when this method executes, the URL fired is of the below form
http://example.com/checkuser.php?username=stackexchange
Here "username" is what we would call a query parameter. To get the value of a GET query parameter in PHP, you would need to use the $_GET superglobal, which is an associative array.
So, to access the value of the username GET param, you would need to do something like the below
$username = $_GET["username"];
That's pretty much it. :-)
Upvotes: 2