基于jquery的跨域調(diào)用文件
更新時間:2010年11月19日 18:23:04 作者:
利用jquery.getScript()跨域調(diào)用文件,具體說這個文件可以是什么類型還有待于進一步跟進。
官方的文檔特別說明,該函數(shù)只適用于1.2以后的版本,之前的版本是不行滴。
function GetCrossDomainContent() {
$.getScript("http://two.xthost.info/im0417/cnblogs.txt", function() { if (typeof (msg) != "undefined") { $("#TestCrossDomain").val(msg[0]); }
});
官方解釋
jQuery.getScript(url, [callback])
參數(shù)1:url,String類型。待載入 JS 文件地址。
參數(shù)2:callback (可選),F(xiàn)unction類型。成功載入后回調(diào)函數(shù)。
<p><input id="TestCrossDomain" type="button" value="點擊獲取跨域內(nèi)容" /></p>
<script type="text/javascript">// <![CDATA[
$("#TestCrossDomain").click(function(){
GetCrossDomainContent();
});
function GetCrossDomainContent() {
$.getScript("http://two.xthost.info/im0417/cnblogs.txt", function() { if (typeof (msg) != "undefined") { $("#TestCrossDomain").val(msg[0]); } });
}
// ]]></script>
詳細參考:http://www.dbjr.com.cn/shouce/jquery/jquery_api/Ajax/$.getScript.html
復(fù)制代碼 代碼如下:
function GetCrossDomainContent() {
$.getScript("http://two.xthost.info/im0417/cnblogs.txt", function() { if (typeof (msg) != "undefined") { $("#TestCrossDomain").val(msg[0]); }
});
官方解釋
jQuery.getScript(url, [callback])
參數(shù)1:url,String類型。待載入 JS 文件地址。
參數(shù)2:callback (可選),F(xiàn)unction類型。成功載入后回調(diào)函數(shù)。
復(fù)制代碼 代碼如下:
<p><input id="TestCrossDomain" type="button" value="點擊獲取跨域內(nèi)容" /></p>
<script type="text/javascript">// <![CDATA[
$("#TestCrossDomain").click(function(){
GetCrossDomainContent();
});
function GetCrossDomainContent() {
$.getScript("http://two.xthost.info/im0417/cnblogs.txt", function() { if (typeof (msg) != "undefined") { $("#TestCrossDomain").val(msg[0]); } });
}
// ]]></script>
詳細參考:http://www.dbjr.com.cn/shouce/jquery/jquery_api/Ajax/$.getScript.html
相關(guān)文章
jQuery的時間datetime控件在AngularJs中的使用實例(分享)
下面小編就為大家?guī)硪黄猨Query的時間datetime控件在AngularJs中的使用實例(分享)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-08-08jQuery Mobile和HTML5開發(fā)App推廣注冊頁
jQuery Mobile和HTML5的組合可以直接開發(fā)web版的app,下面通過本教程給大家分享jQuery Mobile和HTML5開發(fā)App推廣注冊頁的實例代碼,感興趣的朋友參考下吧2016-11-11jQuery AJAX實現(xiàn)調(diào)用頁面后臺方法和web服務(wù)定義的方法分享
jQuery AJAX實現(xiàn)調(diào)用頁面后臺方法和web服務(wù)定義的方法分享,需要的朋友可以參考下2012-03-03分享2個jQuery插件--jquery.fileupload與artdialog
這篇文章主要介紹了分享2個jQuery插件--jquery.fileupload與artdialog的使用方法及示例,非常的實用,這里推薦給大家。2014-12-12Jquery中$.get(),$.post(),$.ajax(),$.getJSON()的用法總結(jié)
本文是對Jquery中$.get(),$.post(),$.ajax(),$.getJSON()的用進行了詳細的總結(jié)介紹,需要的朋友可以過來參考下,希望對大家有所幫助2013-11-11推薦40款強大的 jQuery 導(dǎo)航插件和教程(上篇)
在下面的集合中,你會發(fā)現(xiàn)很多便利的 jQuery 導(dǎo)航插件和有用的教程,幫助你實現(xiàn)充滿吸引力的網(wǎng)站導(dǎo)航,讓你網(wǎng)站更有組織性和交互性2012-09-09