I have this:
$(document).ready(function() {
$.get('getturn.php', function(data){
if (data!=='4') { alert (' change'); }
if (data=='4') { alert ('no change');}
});
});
getturn.php echoes 4 if the turn is equal to a session id, and it echoes the turn number if otherwise. The getturn.php does as it should, it echoes 4 or a number like 0,1,2,3; however when I get the data like seen above from a different file, and check if it equals to 4, I can’t get the correct answer… What am I doing wrong? I thought we could check if the output was yes with data==’yes’ ? but we can’t check numbers with data==’4′?
Have you done an
alert(data);to see what is returned?I think you should try this slight modification:
Based on this answer: How do the PHP equality (== double equals) and identity (=== triple equals) comparison operators differ?