How to prevent saving data when ajax response is false?
<p>I created a text filed for customer name. Already registered customer will show while clicking that text field. Only that registered customer can entry the data. I used ajax for prevent the new user addition.</p>

<p>this is the ajax:</p>

<pre><code>function validateForm()
    {
        var customerName    =   document.getElementById('customerName').value;
        var customerId      =   document.getElementById('customerId').value;
        var getResponse=0;

        var xmlhttp = new XMLHttpRequest();
            xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200) {
           // document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
          getResponse= xmlhttp.responseText;alert(getResponse);

            if(getResponse=="0")
            {
                return false;
            }


          }

        };

        xmlhttp.open("GET", "customer_check_ajax.php?name="+customerName+"&amp;id="+customerId, true);
        xmlhttp.send();

    }
</code></pre>

<p>and here is the ajax page customer_check_ajax.php :</p>

<pre><code>&lt;?php
require("../../config/config.inc.php"); 
require("../../config/Database.class.php");
require("../../config/Application.class.php");
if($_SESSION['travelType']=='Admin')
{
    $check  =   1;
}
else
{
    $check  =   '';
    $logId  =   $_SESSION['travelId'];
    $proId  =   $_SESSION['proId'];
    $check  =   "proId='$proId'";
}

$cusName = $_REQUEST['name'];
$cusId   = $_REQUEST['id'];

$connection = mysqli_connect(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE);
$qry="select * FROM ".TABLE_ACCOUNTS." WHERE ID='$cusId' and accountName='$cusName' and proId='$proId'";
$res = mysqli_query($connection, $qry);//echo $qry;
$num = mysqli_num_rows($res);
if($num&gt;0)
echo '1';
else
echo '0';
?&gt; 
</code></pre>

<p>here i would get the responses as 0 for new user and 1 for already registered user. But i want to stop saving data when new user addition. Please help me.</p>