diff options
| author | aarne <aarne@chalmers.se> | 2010-10-25 19:56:47 +0000 |
|---|---|---|
| committer | aarne <aarne@chalmers.se> | 2010-10-25 19:56:47 +0000 |
| commit | c5334613c514e129c1bd0d6f489f2c4f61516300 (patch) | |
| tree | 7fca452fa631b3a35d1bf81339c0a37798c5f76f /examples/phrasebook/www | |
| parent | ad28e99f35fe032b0a9ff764acae72016d15c57f (diff) | |
trying to find some inefficiencies in Finnish resource
Diffstat (limited to 'examples/phrasebook/www')
| -rw-r--r-- | examples/phrasebook/www/support.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/examples/phrasebook/www/support.js b/examples/phrasebook/www/support.js index b322aae86..7c34bad82 100644 --- a/examples/phrasebook/www/support.js +++ b/examples/phrasebook/www/support.js @@ -25,6 +25,18 @@ function jsonp(url,callback) document.body.appendChild(script); } +var json = {next:0}; + +// Like jsonp, but instead of passing the name of the ballback function, you +// pass the callback function directly, making it possible to use anonymous +// functions. +function jsonpf(url,callback) +{ + var name="callback"+(json.next++); + json[name]=function(x) { delete json[name]; callback(x); } + jsonp(url,"json."+name); +} + /* --- HTML construction ---------------------------------------------------- */ function text(s) { return document.createTextNode(s); } |
