This question already has an answer here:
How can I make jquery run that $_GET
. I'm trying to remove "Refreshing a page" and that is why I'm trying to use jQuery.
if (isset($_GET['add'])) {
global $db;
$quantity = $db->query('SELECT id, quantity FROM data WHERE id = '.$_GET['add']);
while ($r = $quantity->fetch()) {
if ($r['quantity'] != $_SESSION['data_'.(int)$_GET['add']]) {
$_SESSION['data_'.(int)$_GET['add']]+= '1';
}
}
<script>
$( ".wasd" ).click(function( event ) {
event.preventDefault();
$( "<div>" )
.append( "$_GET add function" )
.appendTo( "#log" );
});
</script>
</div>
Example ajax get request using jQuery:
$.get( "url_of_php_here?add=" + id, function( data ) {
$( ".result" ).html( data );
alert( "Load was performed." );
});