$.getJSON( )的使用方法簡(jiǎn)介
成都創(chuàng)新互聯(lián)服務(wù)項(xiàng)目包括洛南網(wǎng)站建設(shè)、洛南網(wǎng)站制作、洛南網(wǎng)頁(yè)制作以及洛南網(wǎng)絡(luò)營(yíng)銷策劃等。多年來(lái),我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢(shì)、行業(yè)經(jīng)驗(yàn)、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機(jī)構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,洛南網(wǎng)站推廣取得了明顯的社會(huì)效益與經(jīng)濟(jì)效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到洛南省份的部分城市,未來(lái)相信會(huì)繼續(xù)擴(kuò)大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!
$.getJSON( url [, data ] [, success(data, textStatus, jqXHR) ] )
url是必選參數(shù),表示json數(shù)據(jù)的地址;
data是可選參數(shù),用于請(qǐng)求數(shù)據(jù)時(shí)發(fā)送數(shù)據(jù)參數(shù);
success是可參數(shù),這是一個(gè)回調(diào)函數(shù),用于處理請(qǐng)求到的數(shù)據(jù)。
//內(nèi)容頁(yè)面
div id="notice_div"/div
//分頁(yè)控件 div id="notice_pages"/div script var roolurl = "http://" + window.location.host; var urlAshx = roolurl + "/aa/Ashx/NoticeInfo.ashx"; //var pages = 0; //獲取分頁(yè)好的公告內(nèi)容 function GetNoticeList(curr, cid) { $.getJSON(urlAshx, {//參數(shù) action: "notice_action", courseid: cid, page: curr || 1,//向服務(wù)端傳的參數(shù),此處只是演示 nums: 3//每頁(yè)顯示的條數(shù) }, function (datajson) {//成功執(zhí)行的方法 if (datajson != null) { var norice_content = ""; //alert(datajson.pages); $(datajson.rows).each(function (n, Row) { norice_content += " div class='panel panel-default'"; norice_content += " div class='panel-heading'"; norice_content += " h3 class='panel-title'"; norice_content += Row.CreateDate; norice_content += " "; norice_content += Row.Creater; norice_content += " /h3"; norice_content += " /div"; norice_content += " div class='panel-body'"; norice_content += Row.NoticeContent; norice_content += " /div"; norice_content += " /div"; }); $('#notice_div').html(norice_content); //alert(11); //調(diào)用分頁(yè) laypage({ cont: 'notice_pages',//容器。值支持id名、原生dom對(duì)象,jquery對(duì)象?!救缭撊萜鳛椤浚篸iv id="page1"/div pages: datajson.pages,//總頁(yè)數(shù) groups: 5, //連續(xù)顯示分頁(yè)數(shù) skip: false, //是否開(kāi)啟跳頁(yè) skin: '#AF0000', curr: curr || 1, //當(dāng)前頁(yè), jump: function (obj, first) {//觸發(fā)分頁(yè)后的回調(diào) if (!first) {//點(diǎn)擊跳頁(yè)觸發(fā)函數(shù)自身,并傳遞當(dāng)前頁(yè):obj.curr GetNoticeList(obj.curr, cid); } } }) } }); } $(document).ready(function () { GetNoticeList(0, '%=_courseid%') }); /script
php 把數(shù)據(jù)導(dǎo)出到excel表格有多種方法,比如使用 phpExcel 等,以下代碼是直接通過(guò) header 生成 excel 文件的代碼示例:
?php
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:filename=xls_region.xls");
$cfg_dbhost = 'localhost';
$cfg_dbname = 'testdb';
$cfg_dbuser = 'root';
$cfg_dbpwd = 'root';
$cfg_db_language = 'utf8';
// END 配置
//鏈接數(shù)據(jù)庫(kù)
$link = mysql_connect($cfg_dbhost,$cfg_dbuser,$cfg_dbpwd);
mysql_select_db($cfg_dbname);
//選擇編碼
mysql_query("set names ".$cfg_db_language);
//users表
$sql = "desc users";
$res = mysql_query($sql);
echo "tabletr";
//導(dǎo)出表頭(也就是表中擁有的字段)
while($row = mysql_fetch_array($res)){
$t_field[] = $row['Field']; //Field中的F要大寫,否則沒(méi)有結(jié)果
echo "th".$row['Field']."/th";
}
echo "/tr";
//導(dǎo)出100條數(shù)據(jù)
$sql = "select * from users limit 100";
$res = mysql_query($sql);
while($row = mysql_fetch_array($res)){
echo "tr";
foreach($t_field as $f_key){
echo "td".$row[$f_key]."/td";
}
echo "/tr";
}
echo "/table";
?等等 許多, 具體的在后盾網(wǎng)里面有詳細(xì)的。
//以下將以jquery.ajax為例,演示一個(gè)異步分頁(yè)
function?demo(curr){
$.getJSON('test/demo1.json',?{
page:?curr?||?1?//向服務(wù)端傳的參數(shù),此處只是演示
},?function(res){
//此處僅僅是為了演示變化的內(nèi)容
var?demoContent?=?(new?Date().getTime()/Math.random()/1000)|0;
document.getElementById('view1').innerHTML?=?res.content?+?demoContent;
//顯示分頁(yè)
laypage({
cont:?'page1',?//容器。值支持id名、原生dom對(duì)象,jquery對(duì)象?!救缭撊萜鳛椤浚篸iv?id="page1"/div
pages:?res.pages,?//通過(guò)后臺(tái)拿到的總頁(yè)數(shù)我還是比較推薦你去后盾人上面看看里面有很多這類php之類的教學(xué)講解視頻哦
action直接空,直接用submit按鈕,點(diǎn)擊不就提交到當(dāng)前頁(yè)面了額,input id="submit1" name="submit1" type="button"你這個(gè)地方干嘛用button,用submit按鈕額
我這樣說(shuō)或許你還不懂,就去找后盾人吧,我在后盾人學(xué)了很多
當(dāng)前名稱:layui取php數(shù)據(jù),layui獲取元素
當(dāng)前路徑:http://sd-ha.com/article26/hdhejg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站制作、微信公眾號(hào)、網(wǎng)站設(shè)計(jì)、全網(wǎng)營(yíng)銷推廣、網(wǎng)站導(dǎo)航、Google
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)