I have the following JS code:
var dataString = "action=validateUsername"+
"&username="+usernameRegi+
"&lang="+lang;
$.ajax({
type: "POST",
url: "function.php",
data: dataString,
cache: false,
success: function(result)
{
var expl=result.split("|");
if(expl[0]=="1")
alert("1");
else if(expl[0]=="99")
alert("99");
}
});
This is my function.php
if($_POST["action"]=="validateUsername")
{
$username=$_POST["username"];
$lang=$_POST["lang"];
$sqlSelect = "SELECT * FROM user where userName='".$username."'";
$sqlQuery = mysql_query($sqlSelect);
$rowCount = mysql_num_rows($sqlQuery);
if($rowCount>0)
{
if($lang=="BM")
echo "99|My msgA.";
else
echo "99|My msgB.";
}
else
{
if($lang=="BM")
echo "1|My msgC.";
else
echo "1|My msgD.";
}
}
The problem is, my ajax request never alert 1 or 99 on success. And I found the problem is expl[0]==1 instead of expl[0]=="1".
When I turn my code to this one, it run smooth.:-
if(expl[0]==1)
alert("1");
else if(expl[0]==99)
alert("99");
This is happen only when I upload my code to the server. No problem on the localhost. What is the problem, is there any setting on the server that cause that problem?
Could anybody explain me, what is happening here?