• JSONP简单示例


    
    

    <!DOCTYPE html>

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>无标题页</title>
         <script type="text/javascript">
             var script = document.createElement("script");
             script.type = "text/javascript";
             script.src = "IbeaconHandler.ashx?op=callBack";
             document.getElementsByTagName("head")[0].appendChild(script);
             //回调函数
             function callBack(jsonp) {
                 alert(jsonp.name);  //judy
             }
        </script>
    </head>
    <body>
    </body>
    </html>

    后台代码:
    <%@ WebHandler Language="C#" Class="IbeaconHandler" %>
    
    using System;
    using System.Web;
    
    public class IbeaconHandler : IHttpHandler {
        
        public void ProcessRequest (HttpContext context) {
            context.Response.ContentType = "text/plain";
            string fname = context.Request.QueryString["op"].ToString();
            string str =fname+"({name:'judy',age:'23'})";
            context.Response.Write(str);
        }
     
        public bool IsReusable {
            get {
                return false;
            }
        }
    
    }
  • 相关阅读:
    对deferred(延迟对象)的理解
    string 、char* 、 char []的转换
    char* 和 cha[]
    层序遍历二叉树
    之字形打印二叉树
    右值
    函数指针(待修改)
    top k

    哈夫曼编码
  • 原文地址:https://www.cnblogs.com/zcttxs/p/3179590.html
Copyright © 2020-2023  润新知