跨域名设置cookie或获取cookie

可以使用jquery里面的ajax中的jsonp的方式来访问就可以了。代码如下:

 1 $.ajax({
 2     url: 'your url',
 3     data: {'xx' : 'xx', 'xx2' : 'xx2'},
 4     success: function(data){    
 5         //成功后执行的
 6     },
 7     type:'GET',
 8     dataType: 'jsonp',//重要的是这个
 9     jsonp: "callback",
10     jsonpCallback:"jsonpReturn"
11 });

 

php中可以这样写:

1 function login()
2 {
3     return 'jsonpReturn('.jsondecode($array).')';
4 }

 

posted @ 2013-07-26 15:18  凹甲  阅读(604)  评论(0编辑  收藏  举报