ʹÓÃjQueryµÄAjax»ñÈ¡Êý¾Ý£¬
html:
javascript´úÂëÈçÏ£º
jQuery(document).ready(function($) { $('.files-show').on('click', function(event) { var $contents = $('.file-list-content'), $url = "/files"; $.ajax({ type : "get", url : url, data : {}, success : function(res){ // console.log(res); $contents.html(res); } }); }); });ÉÏÃæµÄ´úÂëÖ´ÐкóÔÚsuccessÖÐÈôÊÇcosole.log(res);¿ØÖÆ̨»áÏÔʾ´òÓ¡³öÊý¾Ý£¬µ«Èç¹ûÊÇÏÂÒ»¾ä$contents.html(res);ÕâʱºòÒ³ÃæµÄËùÓеã»÷ʼþ¶¼ÎÞ·¨µã»÷ÁË£¬²¢ÇÒ¿ØÖÆ̨Ìáʾ¾¯¸æ£º
Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, checkw3cschoolÉϵĽâÊÍ£º
async ÀàÐÍ£ºBoolean ĬÈÏÖµ: true¡£ ĬÈÏÉèÖÃÏ£¬ËùÓÐÇëÇó¾ùΪÒì²½ÇëÇó¡£Èç¹ûÐèÒª·¢ËÍͬ²½ÇëÇó£¬Ç뽫´ËÑ¡ÏîÉèÖÃΪ false¡£ ×¢Ò⣬ͬ²½ÇëÇó½«Ëøסä¯ÀÀÆ÷£¬Óû§ÆäËü²Ù×÷±ØÐëµÈ´ýÇëÇóÍê³É²Å¿ÉÒÔÖ´ÐС£ÔÚAjaxÖмÓÉÏasync:trueÒÀȻûÓá£
ºǫ́ʹÓÃYii£¬ÎÒÖ±½ÓäÖȾµÄÒ»¶Îhtml·µ»Ø£º
public function actionIndex() { $files = File::find()->where(['enable' => '1'])->orderBy('id DESC')->all(); if ($files) { $page = $this->renderPartial('files', array( 'files' => $files ), true); return $page; } }äÖȾµÄÊÇÒ»¸öºÜ¼òµ¥µÄtable£º
<table> <thead> <tr> <th><h3>ID</h3></th> <th><h3>ÎļþÃû</h3></th> <th><h3>ÀàÐÍ</h3></th> <th><h3>´óС</h3></th> <th><h3>ÏÂÔØ´ÎÊý</h3></th> <th><h3>²Ù×÷</h3></th> </tr> </thead> <tbody> <?php foreach ($files as $file) : ?> <tr> <td><?php echo $file->id; ?></td> <td><?php echo $file->name; ?></td> <td><?php echo $file->filetype; ?></td> <td><?php echo $file->filesize ?></td> <td><?php echo $file->download_num ?></td> <td> <div data-am-dropdown> <button data-am-dropdown-toggle><span></span> <span></span></button> <ul> <li><a href="#">1. ±à¼</a></li> <li><a href="#">2. ÏÂÔØ</a></li> <li><a href="#">3. ɾ³ý</a></li> </ul> </div> </td> </tr> <?php endforeach;?> </tbody> </table> <script src="/js/amazeui.min.js"></script>ÔÚä¯ÀÀÆ÷¿ØÖÆ̨ÖÐÊä³öres½á¹û¾ÍÊÇtableµÄÄÚÈÝ¡£
Âé·³Çë½â´ðһϣ¬Ð»Ð»¡£
¡¡