jsonp sample

  1. $.ajax({
  2. type:"get",
  3. async:false,
  4. dataType: 'JSONP',//here
  5. jsonp: 'callback',
  6. url : "<?php echo $www;?>/article/getmyshare",
  7. //data:'uid='+<?php echo $agent['u_id'];?>+'&page='+page,
  8. data:{'uid':<?php echo $agent['u_id'];?>, 'page':page},
  9. success:function(ret){
  10. //var info = JSON.parse(ret);
  11. var info = (ret);
  12. if(click && info.length ==0) alert('没有了');
  13. var ashare='';
  14. for(var i=0; i<info.length; i++){
  15. ashare += '<a href=<?php echo $rest.'mreading_info?uid='.$agent['u_id'].'&aid=';?>'+info[i].a_id+'><img src="'+info[i].a_image+'" width="100" height="65" ><p style="font-size:15px;">'+info[i].a_short_title+'</p></a>';
  16. }
  17. $('.meShare .list').append(ashare);
  18. }
  19. });
echo $callback."(".json_encode($myshare).")";




原文地址:https://www.cnblogs.com/shudai/p/4669502.html