Ajax updating database when a checkbox is checked
<p>Hi I am trying to update a database table by clicking on a checkbox but it's not working.</p>

<p>HTML:</p>

<pre><code>&lt;input name="no_cage" id="no_cage" type="checkbox" value="1" onclick="chkit(&lt;?php echo $estimate_id; ?&gt;,'no_cage');" &lt;?php echo $checked; ?&gt;
</code></pre>

<p>AJAX:</p>

<pre><code>function chkit(estimate_id, no_cage) {
    chk=document.getElementById("no_cage").checked;

    $.ajax({
            type: 'GET',
            url: 'ajax.php',
            data: { chkYesNo: no_cage, estimate_id: estimate_id}

        });
}
</code></pre>

<p>ajax.php</p>

<pre><code>&lt;?php

error_reporting(E_ALL);

include($_SERVER["DOCUMENT_ROOT"]."/dbconnect.php");

$get=$_GET['chkYesNo'];

$get_id=$_GET['estimate_id'];
if($get=="1")
{
    $sql = "UPDATE estimates SET
            no_cage = '1',
            cage_linear_feet = '',
            cage_doors = '',
            cage_options = '',
            cage_labor = ''
            WHERE estimate_id = '".$get_id."'";

    if ($conn-&gt;query($sql) === TRUE) {
        echo "";
    } else {
        echo "Error: " . $sql . "&lt;br&gt;" . $conn-&gt;error;
    }
}
else
{

}
?&gt;
</code></pre>

<p>Can anyone see what is I'm missing? I am no expert and have been playing around with the for quite a while with no luck.</p>

<p>Thanks,</p>

<p>John</p>