Reputation: 897
I have a page with 6 charts. When user opens page for the first time, I want to load only the layout of the page, and then separately each chart with ajax, because it takes few seconds for each chart to generate on server side. Is it possible to do this with razor syntax using @Ajax.BeginForm, or is it better with JQuery?
Upvotes: 2
Views: 2205
Reputation: 4886
I would argue that it would be better to use jquery. The reason for that is that Ajax.BeginForm will output a form, and that would only make sense if you expect it to be used to send data back to the server.
If all you want to do is load the charts asynchronously it's probably best to use query, for example:
$(function(){
$('#divForChart1').load('@Url.Action("ActionThatGeneratesChart1", "ChartController");
$('#divForChart2').load('@Url.Action("ActionThatGeneratesChart2", "ChartController");
...
});
Upvotes: 1