Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery, ajax logic issue
    primarykey
    data
    text
    <p>I am having some problems with my code. And i thought i would share my problem with the great minds on this website to see if someone can give my brain some pointers on how to solve it.</p> <p>I am working on an app (JQuery, PhoneGap) and i have a login function. The Login function sends login credentials to a webservice. So i am sending it using JQUery ajax. The webservice also contains a fetchData function that let´s my client to get some data. The webservice will check to see if i am currently logged in and that my session hasn´t timed out. If it has timeout i need to login again. And then try again. This is something the user will never see. loginUser() is a function that is used many other times in my code. So don´t want to fiddle around with it to much so i have to make alot of changes.</p> <p>So here is some psuedo code:</p> <pre><code>function loginUser() { $.ajax( { .... success: function(data,status) { //everything worked great return true; }, error: function(data,status) { //display some user error stuff. return false; }, }); } function getData() { $.ajax( { ... success: function(data,status) { //everything worked great. No need to login user again. }, error: function(data,status) { //Opps user needs to login again and then we need to try again. //If we have tried to getData after we tried to login (and got succeess from the loginUser() function)....report error. //Below code will not work. But it will show you roughly what i am trying to do. It will also create an infinite loop. if (loginUser()) { getData(); } }, }); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload