I’m having trouble bringing back data from my PHP file. I guess I don’t really understand the data parameter of this jquery function so I just went off some tutorials.
Jquery
$.ajax(
{
url: 'test.php',
dataType: 'text',
data: {test: '1'},
success: function(data)
{
window.alert(data);
}
})
Now from my understanding the test: declares the variable used in php and 1 is the value in that variable. But I’m not entirely sure…
Here’s my PHP
$item1 = $_POST['test'];
echo $item1;
Now it’s just supposed to alert that value so I know it is at least returning something but in the alert it’s just blank so I’m losing the value somewhere, but where?
use
$_REQUESTit will handle both theGETandPOSTby default ajax request is
GETtype, either specify expilicitly thetypelikeor use
$_GETlike