简体   繁体   中英

How can I pass a value to a javascript function?

I have a function like this:

retrieveData();

and then javascript code like this:

var retrieveData = function ()
        {
            function () { $('#updater').show(); }
            $.post('......

This is I think a simple question but how can I pass an argument to the retrieveData function and have it availabe for use in the code following the.post?

var retrieveData = function (answer) {
  $.post('The answer is ' + answer);
}

retrieveData(42);

Simply

var retrieveData = function (a) {
   $.post(...);
   // use `a` here
}

retrieveData("some value");

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