<div class="grid--cell fl1 lh-lg">
<div class="grid--cell fl1 lh-lg">
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, <a href="/help/reopen-questions">visit the help center</a> for guidance.
</div>
</div>
</div>
<div class="grid--cell mb0 mt8">Closed <span title="2013-06-18 17:59:47Z" class="relativetime">6 years ago</span>.</div>
</div>
</aside>
I know jQuery is currently everybody's darling hammer (truth be told, I'm enamored with it, too), but I'm wondering if dynamically generating html might be more elegantly, or more easily, done using Razor/C#. For example, to update a page, consider this Razor pseudocode:
@{
var divContent = functions.getDivContent("Platypus");
if(IsPost)
{
divContent = functions.getDivContent(request[mammalName]);
}
else
{
;//anything?
}
}
//The getDivContent() function in functions (not shown) returns dynamically generated html
HTML pseudocode:
<body>
<form method="POST" action="" >
<input type="Select" name="mammalName" ... />
</form>
<div>@divContent</div>
</body>
jQuery pseudocode:
$('mammalName').selectionChanged() {
$('form').submit();
});
Doing all of this in a jQuery function, such as using json data and calling .getJson(), would obviate the need for a complete page refresh, but in either case the server has to be queried for data, so I don't know if that's really such an advantage, especially in the case (mine) where the part of the page being refreshed is the lion's share of the page.
Is there a flaw in my thinking/design? Is there a compelling reason to choose jQuery over Razor here?
</div>