跨域

server (http://www.b.com/IP.aspx)

protected void Page_Load(object sender, EventArgs e)


    string callback = Request.QueryString["callback"];
    
//testCallback({ip:'192.168.1.1'})
    Response.Write(string.Format("{0}({{ip:'{1}'}})", callback, "192.168.1.1"));
}


client (http://www.a.com/test.aspx);

$(function(){
    $.getJSON(
'http://www.b.com/IP.aspx?callback=?',function(data){
        alert(data.ip);
    });

}); 

posted @ 2011-04-19 10:39  死 神  阅读(125)  评论(0编辑  收藏  举报