第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

前后端交互問題

前后端交互問題

慕勒5811226 2016-07-09 22:22:33
<!doctype?html> <html> <head> <meta?charset="utf-8"> <title>無標(biāo)題文檔</title> <script> function?fn1(data){ var?oUl1?=?document.getElementById('ul1'); var?html?=?''; for(var?i=0;i<data.length;i++){ html?+='<li>'+data[i]+'</li>'; }; oUl1.innerHTML?=?html; } function?fn2(data){ var?oUl2?=?document.getElementById('ul2'); var?html?=?''; for(var?i=0;i<data.length;i++){ html?+='<li>'+data[i]+'</li>'; }; ?oUl2.innerHTML?=?html; } function?fn3(data){ var?oUl3?=?document.getElementById('ul3'); var?html?=?''; for(var?i=0;i<data.length;i++){ html?+='<li>'+data[i]+'</li>'; }; ?oUl3.innerHTML?=?html; } </script> <!--<script?src="2.txt"></script>--> <script> window.onload?=?function(){ var?oBtn1?=?document.getElementById('btn1'); var?oBtn2?=?document.getElementById('btn2'); var?oBtn3?=?document.getElementById('btn3'); oBtn1.onclick?=?function(){ //當(dāng)按鈕點擊的時候再去加載遠(yuǎn)程資源,讓他執(zhí)行。 var?oScript?=?document.createElement('script'); oScript.src?=?'getData.php?callback=fn1'; document.body.appendChild(oScript); }; oBtn2.onclick?=?function(){ //當(dāng)按鈕點擊的時候再去加載遠(yuǎn)程資源,讓他執(zhí)行。 var?oScript?=?document.createElement('script'); oScript.src?=?'getData.php?t=str&callback=fn2'; document.body.appendChild(oScript); }; oBtn3.onclick?=?function(){ //當(dāng)按鈕點擊的時候再去加載遠(yuǎn)程資源,讓他執(zhí)行。 var?oScript?=?document.createElement('script'); oScript.src?=?'getData.php?callback=fn3'; document.body.appendChild(oScript); }; }; </script> </head> <body> <input?type="button"?id="btn1"?value="加載數(shù)字"?/> ????<ul?id="ul1"></ul> ????<input?type="button"?id="btn2"?value="加載字母"?/> ????<ul?id="ul2"></ul> ????<input?type="button"?id="btn3"?value="加載字母"?/> ????<ul?id="ul3"></ul> </body> </html><?php $t?=?isset($_GET['t'])???$_GET['t']?:?'num'; $callback?=?isset($_GET['callback'])???$_GET['callback']?:?'fn1'; $arr1?=?array('111111','22222222','33333333','4444444','555555555555555555555'); $arr2?=?array('aaaaaaaaaaaa','bbbbbbbb','cccccccccccc','ddddddddd','eeeeeeeeeeee'); if?($t?==?'num')?{ $data?=?json_encode($arr1); }?else?{ $data?=?json_encode($arr2); } echo?$callback.'('.$data.');';當(dāng)點擊的時候執(zhí)行對應(yīng)的回調(diào)fn,后臺是怎樣找到是對應(yīng)的數(shù)組的?還有$t?=?isset($_GET['t'])???$_GET['t']?:?'num';這個$_GET['t']是指哪一個?
查看完整描述

1 回答

已采納
?
super_mb

TA貢獻(xiàn)101條經(jīng)驗 獲得超107個贊

通過$_GET數(shù)組可以取得由get請求通過URL參數(shù)傳遞給當(dāng)前腳本的變量的數(shù)組,而$_GET['t']應(yīng)該就是指的:

oScript.src?=?'getData.php?t=str&callback=fn2';

這一句中的t,$_GET['t']獲取的值就是這里的str。

查看完整回答
2 反對 回復(fù) 2016-07-10
  • 1 回答
  • 0 關(guān)注
  • 1726 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號