0

I have main page with table ,currently when I run my project and open the page the page is load with all the data which can take some time and I want to avoid it...

I've button of load in the page and I want that just when user click on this button load the table and not by default ,

how should I do that ?

How should I know if the user click on this button to load the data in the index page since when I run the project the index is called before the

view...

07_05_GuyT
  • 2,787
  • 14
  • 43
  • 88
  • you might need [ajax](http://stackoverflow.com/questions/1510011/how-does-ajax-work) to load the data in json type when the button is clicked then construct the html.. – Yuliam Chandra Jul 10 '14 at 07:49

1 Answers1

0

You can move the table to partial view and use AJAX to load the table to main view when button is clicked.

EXAMPLE

$( "#button" ).click(function() {
    $.ajax({
        type: "GET",
        url: "/controller/method/" /* This method should return a partial view that contains the table */
    })
    .done(function( html ) {
        $("#tabel").html(html);
    });
});

Thanks!

Saranga
  • 3,178
  • 1
  • 18
  • 26