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.
- function validUser() {
- $.get("backend.php", {task: "check_User"}, function(data) {
- alert(data);
- if(data == 1) {
- return true;
- }
- });
- }
- $(document).on("pageshow", "#sitzung", function () {
- if(validUser()) {
- $("#sitzung-txt").html("Sie haben eine gültige Sitzung!");
- } else {
- // it always points here, so false from validUser()?
- $("#sitzung-txt").html("Sie haben keine gültige Sitzung!");
- }
- });
any ideas, where i make my mistake?
Michael