jQuery’s JSONP Explained with Examples

javascript  type="text/javascript" src="https://code.jquery.com/jquery-3.1.1.min.js"

javascript
jQuery(function($){
    $.ajax({
        type: 'GET',
        url: 'https://server_path/jsonp2.php',
        data: {
            field: 'value valami'
        },
        dataType: 'jsonp' ,
        crossDomain: true
       
    })
    .done(function(response){
       // console.log(response);
        alert(JSON.stringify(response));

alert( response.field);


    })
    .fail(function(error){
        console.log(error.statusText);
    });
});
javascript end



header('Content-type: application/x-javascript');
echo $_GET['callback']."(".json_encode($_GET).")";

githubgist: https://gist.github.com/appastair/3865796

sitepoint: https://www.sitepoint.com/jsonp-examples/

stackoverflow: https://stackoverflow.com/questions/7613815/callback-function-for-jsonp-with-jquery-ajax

Blogbook : PHP | Javascript | Laravel | Corcel | CodeIgniter | VueJs | ReactJs | WordPress