How do I create a random method name

Posted by Russ Bradberry on Stack Overflow See other posts from Stack Overflow or by Russ Bradberry
Published on 2010-03-12T19:26:50Z Indexed on 2010/03/12 20:27 UTC
Read the original article Hit count: 262

I plan on using JSONP to call an external webservice to get around the fact that I dont want to create a global function that could potentially conflict with the calling page. I thought that creating a random function name and passing it up would work. Something like this:

<script src="www.foo.com/b?cb=d357534">

where cb is the callback function name, the server would return

d357534({my json data});

what i want to know is how to create the random function name, im sure i could use eval but is this the best way to go about it?

essentially, what i am trying to do is this:

var d + Math.floor(Math.random()*1000001) = function(){...   

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jsonp