AJAX跨域请求

来源:互联网 发布:choice数据excel插件 编辑:程序博客网 时间:2024/04/30 11:36

服务器端

if($_REQUEST['callback']){

    $json_string = $_REQUEST['callback'].'('.json_encode($result).')';
}else{
    $json_string = json_encode($result);
}

echo $json_string;

客户端

$.ajax({
url:chat_path+'/send_msg.php?tjjtds=tjjtds&wstcwps=wstcwps&callback=?',

type: 'GET',

data: {},

dataType:'json',

success:function(data){}

});


原创粉丝点击