anonymoussc
Sep 6, 2015 • 1 min read

Jsonp definition and example

JSONP or “JSON with padding” is a communication technique used in JavaScript programs running in web browsers to request data from a server in a different domain, something prohibited by typical web browsers because of the same-origin policy. - JSONP - Wikipedia, the free encyclopedia

Example (simple jQuery-driven AJAX call) :

/**
 * Created by anonymoussc on 9/6/15 11:20 PM.
 */

$.ajax({
    url         : "https://path/to/resource/",
    dataType    : 'jsonp',
    crossDomain : true,
    success     : function (data) {
        $('#list').html(data.count + 'True');
    },
    error       : function (data) {
        $('#list').html('False');
    }
});

The kind of programming that C provides will probably remain similar absolutely or slowly decline in usage, but relatively, JavaScript or its variants, or XML, will continue to become more central. - Dennis Ritchie

Post by: Anonymoussc (@anonymoussc)