$.get() AJAX call not being able to handle server response

voqwpi

New Member
This might spund a little bit funny, didn't even know how to put the title at first. It could be due to long hours of work or I'm just doing something wrong.I have a file, say comment.php, which contains something similar to:\[code\]var params = $('form#myform').serialize();$.get("/ajax/file.php?"+params, function(data){ if (data =http://stackoverflow.com/questions/3896386/='error') { $('#message').html('Error'); } else if (data =http://stackoverflow.com/questions/3896386/='success') { $('#message').html('Success'); }});\[/code\]I checked it with firebug and everything is ok, no JS errors, the file is being called and returns either 'error' either 'success', but still, in the body of the ajax call data doesn't match the server response. I then changed \[code\]if (data =http://stackoverflow.com/questions/3896386/='error') { $('#message').html('Error');} else if (data =http://stackoverflow.com/questions/3896386/='success') { $('#message').html('Success');}\[/code\]with\[code\]if (trim(data) == 'error') { $('#message').html('Error');} else if (data =http://stackoverflow.com/questions/3896386/='success') { $('#message').html('Success');}\[/code\]where trim() is a function I wrote that removes any spaces before or after the string. I also tried wit the file being called echoing numbers and making the check with jQuery like:\[code\]if (data =http://stackoverflow.com/questions/3896386/= 1) { $('#message').html('Error');} else if (data =http://stackoverflow.com/questions/3896386/='success') { $('#message').html('Success');} \[/code\]with no results. If I only alert(data) everything looks fine tough. Both files are on the same domain. My code is exactly as in the example just that I have more if/else conditions and one of them should allways match (it does if I look in firebug). I also tried using a switch statement with no result.I've been using this method for some time now and never had any problems. Ideas?
 
Top