Home > front end >  Help see this callback function execution order problem?
Help see this callback function execution order problem?

Time:09-15

 
//in the variables, but in other js code on a page called
Var hdfWxh;
Var hdfWxhName;
Var hdfWxhSex;
Window. _hdf. Callback=function (data) {
/* *
* get WeChat ID information js variable, and assign a value to a custom global variable
*/
HdfWxh=data. WXH;//WeChat ID
HdfWxhName=data. Wxh_name;//WeChat ID name
HdfWxhSex=data. Wxh_sex;//gender

};

The function get_wxh ()
{
The console. The log (hdfWxh);
$(' zaax WXH - '). Attr (' id ', '22222');
}

How is this execution sequence backwards, the output is empty,

CodePudding user response:

Actually very simple, you can directly in the callback function calls to functions that you need not to go, the code is as follows:
 
//in the variables, but in other js code on a page called
Var hdfWxh;
Var hdfWxhName;
Var hdfWxhSex;
Window. _hdf. Callback=function (data) {
/* *
* get WeChat ID information js variable, and assign a value to a custom global variable
*/
HdfWxh=data. WXH;//WeChat ID
HdfWxhName=data. Wxh_name;//WeChat ID name
HdfWxhSex=data. Wxh_sex;//gender
Get_wxh (hdfWxh);
};

The function get_wxh (WXH)
{
The console. The log (hdfWxh);
$(' zaax WXH - '). Attr (' id ', '22222');
}

CodePudding user response:

Get_wxh this method did not trigger
You the section of code defines the method just didn't call

CodePudding user response:

The callback execution inside get_wxh ()
  • Related