javascript JSONP callback function not defined

Posted by bitsMix on Stack Overflow See other posts from Stack Overflow or by bitsMix
Published on 2010-12-24T19:49:54Z Indexed on 2010/12/24 19:54 UTC
Read the original article Hit count: 227

Filed under:
|
(
function restoreURL() {
    function turnLongURL(data) {
        window.location = data.url;
    }

    var shortUrl = window.location.href;

    var url = "http://json-longurl.appspot.com/?url=" + shortUrl + "&callback=turnLongURL";

    var script = document.createElement('script');
    script.setAttribute('src', url);

    document.getElementsByTagName('head')[0].appendChild(script); 
})();

code is above, but the firebug told me, turnLongURL is not defined

why is that?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jsonp