-
09-06
-
12-27
-
01-08
-
12-31
-
12-31
Warning: error_log(/home/wwwroot/zym.qw1688.net/cache/error_log.php): failed to open stream: Permission denied in /home/wwwroot/zym.qw1688.net/yzmphp/core/class/debug.class.php on line 63
发布时间:2021-01-08 13:03:41
文章来源:原创
访问次数:4
09-06
12-27
01-08
12-31
12-31
原来打算做插件用的,没想到插件不支持,那也只能先记下了。
<html>
<head>
<title>跨域测试</title>
<script src="http://cdn.fh.lykep.com/antired2.0/js/jquery.min.js"></script>
<script>
$(document).ready(function () {
$("#btn").click(function () {
$.ajax({
url: "http://t.ly404.cn/api.php?url=https://www.lykep.com/",
type: "GET",
success: function (data) {
$("#text").val(data);
}
});
});
});
</script>
</head>
<body>
<textarea id="text" style="width:400px; height:100px;"></textarea>
<input id="btn" type="button" value="跨域获取数据" />
</body>
</html>
后台代码:
<?php
header('Access-Control-Allow-Origin: *');//必须
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept');//必须
echo '数据';(登陆可见)本文链接:http://www.hzlm.net/javascript/79.html