[英]how to solve this in java script and ajax one Alert show in ajax if value are right
I know this is silly Question but i have occurred this error again and again 我知道这是一个愚蠢的问题,但我一次又一次地发生此错误
My Question is php script are send me the right data but when i set the if condition in 我的问题是 php脚本会向我发送正确的数据,但是当我在其中设置if条件时
success:function(data)
data then show me the one alert if i put the right value and wrong value 数据然后向我显示一个警报,如果我输入正确的值和错误的值
This is Js Code 这是Js代码
function SetTheAmount_man()
{ //Get
var member_id = $('#mem_un_id').val();
// alert(member_id);
$.ajax({
url:"<?php echo
base_url();?>demo_insert.php",
data: {member_id:member_id},
type: "POST",
success:function(data){
//alert(data);
// alert(member_id);
if (data == 'success')
{
alert("123");
}
else
{
alert("456");
}
//window.open('http://www.google.com');
//alert(data);
// $("#secheme_interest_value").html(data);
}
});
}
This is PHP Code demo_insert 这是PHP代码demo_insert
if(isset($_POST['member_id']))
{
$mem_un_id=$_POST['member_id'];
$sql_in= mysql_query("select mem_un_id,deleted from phppos_customers where mem_un_id='".$_POST['member_id']."' and deleted='0'");
//$row = mysql_affected_rows($sql_in);
$row=mysql_fetch_array($sql_in);
if($row['mem_un_id']!=''){
echo "success";
}else{
echo "error";
}
//echo $row['mem_un_id'];
}
@Deepak Acharya: Use the datatype in you ajax hit and then check if it helps, try all the datatypes available most likely to use @Deepak Acharya:在ajax命中中使用数据类型,然后检查是否有帮助,请尝试最有可能使用的所有可用数据类型
What is the result of alerting the incoming response? 警报传入响应有什么结果?
Uncomment this: 取消注释:
//alert(data);
Try to change this: 尝试更改此:
if(data == 'success')
{
alert("123");
}
else
{
alert("456");
}
to this: 对此:
if( data == "success" ) {
alert("123");
}
if( data == "error" ) {
alert("456");
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.