简体   繁体   中英

Load content from same page into a div instead of external link on click

I use the code below to load contents from external link but it is slower depending on the network speed. I want to host the content on same page and load it from it or any idea on how it can load faster irrespective of the internet speed.

<script>
    function dynamic_Select(ajax_page, currency) {
        $.ajax({
            type: "GET",
            url: ajax_page,
            data: "ch=" + currency,
            dataType: "html",
            //dataType: "text/html", //<--UPDATE: DELETING THIS LINE FIXES EVERYTHING
            //<--UPDATE2: DON'T DELETE; REPLACE "test/html" with "html"
            success: function (html) {
                $("#txtResult").html(html);
            }
        });
    }
</script>

My html code is

<input type="radio" name="currency" 
     id="perfectmoney" value="Perfect Money" 
     onChange="dynamic_Select('fetchbuy.php', this.value)" />

Did you try load of JQuery?

    $('#your_div').load(url);

Of course you need that the url will be a controller path where you can render the page with the html code that you want to load

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM