Search Results

Search found 1 results on 1 pages for 'rpmlins'.

Page 1/1 | 1 

  • Jquery mobile function calls before Ajax Request end

    - by rpmlins
    Here is my problem. When My Home page shows, I call the LoadUser functions, which on success, sets the globalUser variable with the returned json, and after it loads I call the alert function but it says globalUser is undefined. I have tried many other work arounds, but I always get the undefined mesage. If I call the alert(globalUser); on the success function, it works as expected alerting the object. $('#Home').live('pageshow', function(event) { $.when(LoadUser()).done(function(a1) { alert(globalUser); }); }); function LoadUser() { $.ajax({ // connects with the web service and validate de user input url: "http://localhost:51396/Icademy.asmx/GetUser", contentType: "application/json; charset=utf-8", data: { "userName": "'rodrigo'" }, dataType: "jsonp", success: function(json) { globalUser = JSON.parse(json.d); return globalUser; }, error: function(ret) { alert("Um erro ocorreu, tente novamente mais tarde."); } }); }

    Read the article

1