user3825068
user3825068

Reputation: 1

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)" />

Upvotes: 0

Views: 461

Answers (1)

paul
paul

Reputation: 13471

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

Upvotes: 1

Related Questions