ajax跨域的返回值怎么输出
在我的getcookie.ashx页面中有如下代码:为了去调用getcookie()去获取服务器端的cookie
public void ProcessRequest(HttpContext context)
{
// context.Response.ContentType = "application/x-javascript";
context.Response.Write("<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>");
context.Response.Write("<script src="http://192.131.0.18:80/jscript/en.js" type="text/javascript"></script>");
context.Response.Write("<script type="text/javascript">");
context.Response.Write(" var a=GetCookie();");
context.Response.Write("document.write(a);");
context.Response.Write("</script>");
}
function GetCookie() {
$.getJSON("http://192.131.0.18:80/ajax/GetCookie.ashx?jsoncallback=?", {},
function (data) {
document.write(data.link) //为什么不会输出呢?
});
}
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
context.Response.Write(context.Request.QueryString["jsoncallback"]+ "({"link":"" + HttpContext.Current.Request.Cookies["lan"].Value+ ""})" );
}