return-value from function always false?

return-value from function always false?

Hi,

i try to get a return-value (1 or 0) from a php-file via ajax-get. The data from the ajax-call is ok, alert(data) shows 1 in data. But i can not return this data to the calling function.

  1. function validUser() {
  2.     $.get("backend.php", {task: "check_User"}, function(data) {
  3.     alert(data);
  4.     if(data == 1) {
  5.     return true;
  6.     }
  7.     });
  8. }
  9. $(document).on("pageshow", "#sitzung", function () {
  10. if(validUser()) {
  11. $("#sitzung-txt").html("Sie haben eine gültige Sitzung!");
  12. } else {
  13.                 // it always points here, so false from validUser()?
  14. $("#sitzung-txt").html("Sie haben keine gültige Sitzung!");
  15. }
  16. });

any ideas, where i make my mistake?

Michael