简体   繁体   中英

How to set global variable in JQuery/javascript

Hi i am new to jquery/javascript. I have created a global variable. I set the value of value of this variable inside function like this:

var arr;
CreatecheckPassword: function() {

                var pas = document.getElementById("pos-password")

                var user = new db.web.Model("res.users").get_func("read")(this.session.uid, ['password']).pipe(function(result) {
                     arr = result.password;
                     alert(arr);//prints the expected value
                });
                alert(arr);//prints nothing
},

I don't know where i am doing wrong. I tried hard but was unable to find the solution. Can someone help.

jslint or jshint is your friend. Get it and use it on your code to get lint messages.

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM