idnoJSONP, or json with padding, is a technique hack that allows you to retrieve json content from a remote page, and pass that content to a Javascript function, without falling foul of the browser XSS same origin policy.

Idno has had a JSON view of it’s data objects for some time, but up until now it has been hard to call that data from within javascript, unless you were doing it from the same domain.

So, I sent Ben a pull request which adds JSONP support to Idno core, together with some enhancements to the data the standard JSON view provides.

6 thoughts on “Sweet, JSONP is now in Idno core

  1. One of the things that I thought it’d be cool to be able to do with Idno, is to be able to embed a post into a blog post, rather like you can with a tweet or public Facebook posting.
    Embedding posts mean that you can take a posting that you or someone else has written on their Idno site, and then build up a conversation around it.
    (function(){
    var e = document.createElement(‘script’); e.type=’text/javascript’; e.async = true;
    e.src = ‘//mapkyca.com/IdnoPlugins/EmbeddedPosts/js/embeddedposts.js’;
    var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(e, s);
    })();
    $(document).ready(function() {
    $.ajax({
    url: ‘https://mapkyca.com/2014/its-a-calm-sunny-day-in-englandshire-off-for-a?_t=jsonp’,
    dataType: ‘jsonp’,
    success: function(jsondata) {
    $(‘#its-a-calm-sunny-day-in-englandshire-off-for-a’).html(idnoGetPostIframe(jsondata.object.url, 500, 200));
    }
    });
    })

    So, I wrote a quick plugin that provides this functionality!
    This current version uses an iframe to display an embed view of the selected object, using code inserted using the JSONP api, which gives you a live view of the object complete with latest comment count and using your site’s theme choices. Future versions of the plugin may make more use of the raw data returned via the JSONP endpoint.
    All links will open in a new tab, so if you want to see the comments (or comment directly, if the site in question uses my in place comments plugin), then you can follow links without causing problems.
    Have fun!
    » Visit the project on Github…
    Thanks for visiting! If you’re new here you might like to read a bit about me. You may also like to follow me on Twitter!

    (Psst… I am also available to hire! Find out more…)
    Share this:EmailLinkedInTwitterGoogleFacebookReddit

  2. Is elgg also supporting jsonp? I want to access my elgg website’s api from another website. I use jsonp for cross origin domain access but because the response is in json I get a Syntax Error: missing ; before statement.

  3. Elgg, like Idno supports a number of different views on data – standard HTML, JSON etc. However, unlike Idno, Elgg does not natively support JSONP.
    JSONP allows you to make cross domain calls using JSON data, and is very handy for querying data from other sources using your fancy-pants javascript/jquery ajax code. It’s how, among other things, the idno feed widget running in the sidebar works.
    Anyway, a commenter on another post asked about Elgg support, and because I had a few minutes spare, I put together a quick plugin!
    » Visit the project on Github…

    Thanks for visiting! If you’re new here you might like to read a bit about me. You may also like to follow me on Twitter!

    (Psst… I am also available to hire! Find out more…)
    Share this:EmailLinkedInTwitterGoogleFacebookReddit

Leave a Reply