美文网首页
简单的jsonp

简单的jsonp

作者: 刘学_b270 | 来源:发表于2018-04-27 06:27 被阅读0次

    //服务器端ashx
    public class Handler2 : IHttpHandler {

    public void ProcessRequest (HttpContext context) {
        HttpRequest Request = HttpContext.Current.Request;
        string callback = Request.QueryString["callback"];
    
        string name = Request.QueryString["name"];
    
        context.Response.Write(callback + "({msg:'this is"+name+"jsonp'})");
    }
    
    public bool IsReusable {
        get {
            return false;
        }
    }
    

    }

    //script
    $.getJSON(
    "http://localhost:63124/Handler.ashx?callback=?",
    { name: "ff", time: "2pm" },
    function(data) { alert(data.msg) }
    );

    相关文章

      网友评论

          本文标题:简单的jsonp

          本文链接:https://www.haomeiwen.com/subject/hzivlftx.html