博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Jquery getJSON 实现跨域请求 --- callback
阅读量:6858 次
发布时间:2019-06-26

本文共 1468 字,大约阅读时间需要 4 分钟。

 当前域名访问  me.com 文件

localhost/test.php 文件
1)).')');?>

 getJSON 核心思想是 执行getJSON  注册一个以当前时间命名的function 然后再服务端执行该函数 (具体源码)

           1、

getJSON: function( url, data, callback ) { return jQuery.get(url, data, callback, "json"); },

   2、

get: function( url, data, callback, type ) {    // shift arguments if data argument was ommited    if ( jQuery.isFunction( data ) ) {        callback = data;        data = null;    }    return jQuery.ajax({        type: "GET",        url: url,        data: data,        success: callback,        dataType: type    });},

  3、

// Build temporary JSONP function        if ( s.dataType == "json" && (s.data && s.data.match(jsre) || s.url.match(jsre)) ) {            jsonp = "jsonp" + jsc++;            // Replace the =? sequence both in the query string and the data            if ( s.data )                s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1");            s.url = s.url.replace(jsre, "=" + jsonp + "$1");            // We need to make sure            // that a JSONP style response is executed properly            s.dataType = "script";            // Handle JSONP-style loading            window[ jsonp ] = function(tmp){                data = tmp;                success();                complete();                // Garbage collect                window[ jsonp ] = undefined;                try{ delete window[ jsonp ]; } catch(e){}                if ( head )                    head.removeChild( script );            };        }

 

 
 
 
 

转载地址:http://bzxyl.baihongyu.com/

你可能感兴趣的文章
Mybatis系列(四):Mybatis缓存
查看>>
python中的列表、元组、数组——是不是特别容易混淆啊??
查看>>
phpmyadmin 自动登录的办法
查看>>
苹果各版本手机更换电池的视频
查看>>
在Centos7.x中安装psutil模块
查看>>
深度学习的异构加速技术(二):螺狮壳里做道场
查看>>
html5--1.10绝对路径和相对路径
查看>>
运维监控系统+堡垒机
查看>>
30岁的思考
查看>>
【转】Linux mysql停止失败的解决办法 Stopping MySQL database server mysqld [fail]
查看>>
tomcat8配置tomcat-users.xml不生效
查看>>
splay树入门(带3个例题)
查看>>
CentOS 6.9使用iptables搭建网关服务器(转)
查看>>
MySQL学习笔记(二)
查看>>
Kafka的生产者和消费者代码解析
查看>>
Intellij Idea编译项目下的.java文件时的编码问题
查看>>
【深度学习系列】PaddlePaddle可视化之VisualDL
查看>>
[离散时间信号处理学习笔记] 11. 连续时间信号的采样与重构
查看>>
python os.system()和os.popen()
查看>>
Tensorflow1.4 高级接口使用(estimator, data, keras, layers)
查看>>