Site Cloner PHP Script
Bargain Hunter PHP Script
Job Hunter PHP Script
Site Login and Access Control PHP Script

Ajax, Jquery and GET Variables

This example uses jquery to make an Ajax call via the ‘GET’ method. This method is coded almost identically to the previous ‘POST’ sample. For example, when you select the checkbox, the Jquery change() function is triggered.

After that, if the check box is checked, a variable = 1 is created. If it is deselected, the variable becomes = 2. Then, asyncronous ajax takes places with the proper data and url. Essentially, new get variables are created when you click the checkbox. Finally, the get variables are used to update the database table with basic php / mySQL.

header('Cache-Control: no cache'); //no chache but no error
include ("");

<script src="//" type="text/javascript"></script>
<script type="text/javascript">
$.ajaxSetup ({
    // Disable caching of AJAX responses
    cache: false
			var variable = $(this).attr("id");
			if ($(this).is(':checked')) {
			var variable2 = 1;
			} else {
			var variable2 = 2;
			/*var dataString = 'variable=' + variable + '&variable2=' + variable2;*/
				type: "GET",
				cache: false,
				url: "ajax-get-jquery.php",
				data: "variable="+variable +"&variable2="+variable2,
				/*data: { variable2: "variable2" },*/
				/*data: dataString,*/
				success: function(msg){
	$command = "SELECT * FROM ajax";
	$result = mysqli_query($db, $command);
	while($row = mysqli_fetch_assoc($result)){

	$variable2 = $_GET['variable2'];
    $variable = $_GET['variable'];

$command = "SELECT * FROM ajax";
	$result = mysqli_query($db, $command);
	while($row = mysqli_fetch_assoc($result)){
	//echo $row['checking'];

echo $variable2;
	$commandb = "UPDATE ajax SET checking='{$_GET['variable2']}' WHERE id=1";
	$resultb = mysqli_query($db, $commandb) ; 
	}	else{
	$commandc = "UPDATE ajax SET checking=3 WHERE id=1";
	$resultc = mysqli_query($db, $commandc) ; 
	<form method ="post" action = "">
<input type= "checkbox" name="mycheckbox" id="checker" value="1" />