Home > front end >  After ajax to global variable assignment to synchronous or not
After ajax to global variable assignment to synchronous or not

Time:04-04

Ajax to global variable assignment to synchronous after fu will not come also asked the great spirit action

CodePudding user response:

Not fu will not come, but you must know when its assignment, if you are to read the variable assignment before it of course is not to read,

CodePudding user response:

To sync is first read made again after calling the ajax or not

CodePudding user response:

refer to the second floor weixin_38834667 response:
to sync is called first read in again after the ajax or not

Synchronization should, however, want to see the code to determine the specific issues

CodePudding user response:

Should ensure that global variables before perform ajax already exists, if before a global variable declaration has not perform ajax affirmation,

CodePudding user response:

Synchronous global assignment sure can, can't you have a problem with the or server side error can't walk the success callback to global variable assignment

Note after post code, or who knows what you have

CodePudding user response:








//global variable
Var userAddG="true";
The function findAuth (th) {
$. Ajax ({
Url: '/findAdminAuth'
Type: "POST",
Async: false,
Data: {accountNumber: th. Id},
Success: the function (data) {
UserAddG1=data. UserAdd;
//access to the data, now the problem is how to modify the data of the above global variable
//userAddG=MSG. UserAdd;
//layer. Alert (userAddG);
//var userDelete=MSG. UserDelete;
//var userUpdate=MSG. UserUpdate;
//var userSelect=MSG. UserSelect;
//var Terminal=MSG. Terminal;
//var gateWay=MSG. The gateWay;
//var serviceAdd=MSG. ServiceAdd;
//var serviceDelete=MSG. ServiceDelete;
//var serviceUpdate=MSG. ServiceUpdate;
//var serviceSelect=MSG. ServiceSelect;
//var historyView=MSG. HistoryView;
//var historyUpdate=MSG. HistoryUpdate;
//var historyDelete=MSG. HistoryDelete;
//var authorityChange=MSG. AuthorityChange;
}
})
}


Layer. Alert (userAddG);
//although the value of the modified userAddG in success, but only temporarily, no real changes to the external data
If (userAddG==="true") {
$(" # userAdd "). Prop (" checked ", true)
} else {
$(" # userAdd "). Prop (" checked ", false)
}

Excuse me, what this I can't access
  •  Tags:  
  • Ajax
  • Related