Cross domain jsonp

function crossript(nid) {
  var urlto = "http://www.xxx.com/xxx.php?url=http://www.xxx.com/" + nid;
  $.ajax({
    url:urlto, 
    dataType:"jsonp",
    jsonp : "callback",
    success:function(data){
     console.log(data.message);
    }
  })
}
/***** php ****/
<?php
 header("content-type: application/json"); 
$url = $_GET['url'];
$obj = new stdClass;
$obj->message = $result;
echo $_GET['callback']. '('. json_encode($obj) . ')';  
?>
Help Share this Article