Ajax return value is assigned to a global variable solution sessionStorage

# Ajax return value is assigned to a global variable solution sessionStorage

While ajax js-valued value to a global variable, the global variable is less than the acquisition, ajax default is asynchronous, synchronous can of course be changed assignment, but a better solution is to use ajax sessionStorage to hold the value obtained in you can get anywhere globally.

sessionStorage.setItem ( 'testKey', 'which is a value test value');

sessionStorage.getItem('testKey');

Guess you like

Origin blog.csdn.net/PKyourself/article/details/86701829