On Mon, May 6, 2013 at 10:14 AM, fei wang <[email protected]> wrote:

> Hi,
>
> Any one can help me about accessing function parameter ?
>
> I have the follow function.
>
> requsetProject : function(pid, idx) {
>                     var req = new
> qx.io.request.Xhr("/hrm/services/ActionServlet2", "POST");
> req.setRequestData({
>         'class' : 'ProjectDAO',
>         'method' : 'queryProject',
>         'args' : "{\"pid\" : \"" + pid + "\"}"
>     });
> req.addListener("success", function(e) {
> var req = e.getTarget();
>  var str = req.getResponse();
>   *// My Question is:*
> * // in here, how to access the parameter 'idx' in outer function*
> }, this);
>  req.send();
> }
>

Given only what you've provided here, by "closure" idx is available in the
listener function. in place of the red comment, you do console.log("idx=" +
idx) and it displays 'undefined', and you've actually given us the full
code for requestProject() other than what's in red, then requestProject()
is being called with something that is undefined. (Try doing that same
console.log immediately upon entering requestProject().)

As others have suggested, though, the final value of idx from
requestProject() is what will be available in the listener function once
it's called. If something later in requestProject() somehow sets idx to
undefined, then that is what will be available when the listener function
is called. It wouldn't hurt to do yet another console.log, right at the
very end of requestProject(), to see what the final value of idx is.

Cheers,

Derrell
------------------------------------------------------------------------------
Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
Get 100% visibility into your production application - at no cost.
Code-level diagnostics for performance bottlenecks with <2% overhead
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap1
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to