クロスドメイン用テスト

2016-05-26 13:28



<style>div#colorbox { background: #ddd; }</style>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.colorbox/1.6.4/jquery.colorbox-min.js"></script>
<!-- <script type="text/javascript" src="https://raw.githubusercontent.com/padolsey-archive/jquery.fn/master/cross-domain-ajax/jquery.xdomainajax.js"></script> -->
<script type="text/javascript" src="https://rawgit.com/padolsey-archive/jquery.fn/master/cross-domain-ajax/jquery.xdomainajax.js"></script>

・追記
raw.githubusercontent.com使うとjsと認識してくれない。
ご指摘ありがとうございました。
代わりにサードパーティですがrawgithubを使う。ちなみに本番使用は非推奨らしい。
参考:CDN代わりにgithubを使いたい場合は外部サービスrawgithubを利用しよう

<script>
$(function() {
	$('#btn_a').on('click',function(){
	    $.ajax({
	        type: 'GET',
	        url: "http://wordpress.information.jp/license.txt",
	        dataType: 'html',
	        success: function(data) {
	            $.colorbox({html:data.responseText, width:"50%", height:"50%"});
	        }, error:function(e) {
	            console.log(e);
	        }
	    });
	});
});
</script>


<script>
$(function() {
	$('#btn_b').on('click',function(){
		$.colorbox({ href:"http://wordpress.information.jp/license.txt", iframe:true, width:"50%", height:"50%"});
	});
});
</script>