跨域

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);
    });

}); 

原文地址:https://www.cnblogs.com/Death/p/2020601.html