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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何在單擊時(shí)使用 jQuery 動(dòng)態(tài)加載 WordPress 自定義帖子類型數(shù)據(jù)?

如何在單擊時(shí)使用 jQuery 動(dòng)態(tài)加載 WordPress 自定義帖子類型數(shù)據(jù)?

PHP
UYOU 2022-01-02 16:29:37
我將嘗試解釋我在這里嘗試做的事情。我創(chuàng)建了一個(gè)名為“人物”的自定義帖子并創(chuàng)建了一些新帖子。現(xiàn)在,我已經(jīng)創(chuàng)建了一個(gè)帶有靜態(tài)內(nèi)容的 JS 模態(tài),它可以工作。但是,我不想在加載頁(yè)面時(shí)加載自定義帖子類型中的所有帖子,而是只想顯示每個(gè)特定 ID 的點(diǎn)擊模式數(shù)據(jù)。而不是在加載時(shí)有 10 或 20 個(gè)相同的模態(tài)輸出 HTML。所以點(diǎn)擊..我想顯示這個(gè)特定CP帖子的數(shù)據(jù)。模態(tài)人物提要 HTML(每個(gè)圖打開(kāi)一個(gè)模態(tài)):<section class="feed">    <div class="container">        <div class="row content">            <h1><?php the_title(); ?></h1>            <div class="feed__inner">                <figure data-post-id="1" class="feed__item">                    <img class="feed__image" data-src="https://images.pexels.com/photos/1845534/pexels-photo-1845534.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940" />                </figure>                <figure data-post-id="2" class="feed__item">                    <img class="feed__image" data-src="https://images.pexels.com/photos/614810/pexels-photo-614810.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940" />                </figure>                <figure data-post-id="3" class="feed__item">                    <img class="feed__image" data-src="https://images.pexels.com/photos/2613260/pexels-photo-2613260.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940" />                </figure>                <figure data-post-id="4" class="feed__item">                    <img class="feed__image" data-src="https://images.pexels.com/photos/2379004/pexels-photo-2379004.jpeg?auto=compress&cs=tinysrgb&dpr=3&h=750&w=1260" />                </figure>如何僅在請(qǐng)求/單擊時(shí)加載模態(tài)數(shù)據(jù)?
查看完整描述

1 回答

?
慕斯709654

TA貢獻(xiàn)1840條經(jīng)驗(yàn) 獲得超5個(gè)贊

你可以用 AJAX 做到這一點(diǎn)。


創(chuàng)建根據(jù) single-people.php需要輸出帖子的文件,并在彈出窗口打開(kāi)時(shí)通過(guò) ajax 請(qǐng)求它。


例如(假設(shè) jquery)


<script>

    function openPopup(id)

    {

        fetch('http://example.com?p='+id).then(

         function(response){

            $('#popup-content').html(response.body);

            $('.popup').show();

         });

    }

</script>


<button onclick="openPopup(1)">Open popup #1</button>

<button onclick="openPopup(2)">Open popup #2</button>


<div class="popup">

<div id="popup-content"></div>

</div>


查看完整回答
反對(duì) 回復(fù) 2022-01-02
  • 1 回答
  • 0 關(guān)注
  • 157 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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