Playing with jsFiddle's ajax testing

by Ronny

JavaScript

function identify(num) {
    console.log('This is snippet #' + num);
}

// simple inline javascript
$.get('/echo/js/?js=' + encodeURIComponent("console.log('This is snippet #1');"));

// echo the function declaration
$.get('/echo/js/?js=' + encodeURIComponent(identify.toString()), function(res) {
    identify(2);
});

// invoke the function immediately
$.get('/echo/js/?js=' + encodeURIComponent('(' + identify + ')(3)'));