tags:

views:

11

answers:

1

This doesn't seem to work:

func = "getProductListings"; 
params = "{'user_id':1234,'short':true}"; 
window.opener[func](params);

can someone check my code please?

+1  A: 

A few points you might want to check out:

  • When a window is opened from another window, it maintains a reference to that first window as window.opener. If the current window has no opener, then this method returns NULL. Is there a parent window? ... And does it have a getProductListings function defined?

  • Does your getProductListings function expect an object as the first argument? In that case, you'd want to remove the double quotes from the params:

    params = {'user_id': 1234, 'short': true};

Daniel Vassallo
Yes, it all follows through to the opener fine, and even reaches the function in the opener, but the following code alerts "undefined": function getProductListings(oArg) { alert(oArg.user_id); }
Paul
@Paul: Yes, that it's because of the second point. You do not want `params` to hold a string, but an object. Simply remove the quotes that wrap the definition.
Daniel Vassallo