<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script>
<SCRIPT type="text/javascript">
$(document).ready(function()
{
$(".promo").change(function()
{
var pre_code = $(".promo").val();
var msgbox = $("#status");
$('#pre').html(pre_code);
if(pre_code.length > 4)
{
$("#status").html('<img src="loader.gif" align="absmiddle"> Checking availability...');
$.ajax({
type: "POST",
url: "promo_chk.php",
data: "pre_code="+ pre_code,
success: function(msg){
if(msg == 'msg')
{
$(".promo").removeClass("red");
$(".promo").addClass("green");
$("#status").html(msg);
}
else
{
$(".promo").removeClass("green");
$(".promo").addClass("red");
$("#status").html('iNVALID');
}
}
});
}
else
{
$(".promo").addClass("red");
$("#status").html('<font color="#cc0000">Please Enter atleast 5 letters</font>');
}
return false;
});
});
</SCRIPT>
promo_chk.php
<?php
require '../db-connect.php';
if(isset($_POST['pre_code']) && !empty($_POST['pre_code'])){
$precode=mysql_real_escape_string($_POST['pre_code']);
$query="select * from prepaid where c_code='$precode'";
$res=mysql_query($query);
$count=mysql_num_rows($res);
if($count > 0){
echo 'msg';
}else{
echo 'Invalid';
}
}
?>
如果陈述是真的,我不会得到。我已经检查了消息值,否则它给出的值与检查的值相同,如果&#39;但只显示其他内容,即&#34; if(msg ==&#39; true&#39;)display&#34; hello&#34;否则显示消息。 &#34;它将转向其他并显示msg内容&#39; true&#39;