Hello guys this is pretty embarrassing. I am returning a string variable from php to javascript. On there I want to make a simple comparison and take action accordingly but the results are not as expected.
First I make a post to a form my javascript file to php for processing.
$('#matchForm3').submit(function (event) {
var pr = $('#cprovider3').val();
var amount = $('#camount3').val();
var ctc = $('#ctc3').val();
var formData = {'cprovider': pr, 'camount': amount, 'ctc': ctc, 'creceiver': rc3, 'ramount': ramount3};
$.ajax({
url: '/backend/matchForm.php',
type: 'post',
data: formData,
success: matchResponce,
error: function (xhr, desc, err) {
alert(xhr);
return false;
}
});
return false;
});
function matchResponce(data, status) {
//alert(data);
if (data != 'legit') {
//do something
}else {
//do something else
}
}
And then in the matchForm.php file I do some processing and return any of two possible values "legit" or "no no".
//do something up here
if(value == true){
echo 'legit';
}else{
echo 'no no';
}
Now back in the script.js file in the callback method matchResponce(). I want to make that check and act accordingly but it meets the first condition every time, even though the data is different. Thanks in advance!!