Can you site Any benefits of using the jquery $开发者_运维百科.post to submit asp.net forms data? When and why should i do it.
$.post is just a shortcut to $.ajax
It can be extremely useful for posting informations without having to reload the whole page (a.k.a. one of the web 2.0 required features).
As a parameter of the $.post call, you can specify a callback function, which can use the retrieved data to update some of the content of your page.
In the provided links you can find very easy and useful examples. This is one of them:
$.post("test.php", { name: "John", time: "2pm" },
function(data){
alert("Data Loaded: " + data);
});
As for the why, you can probably argue that you can achieve any of the abovementioned behaviours with UpdatePanels. True, but i suggest you reading this article from Encosia.
There are times in which you can't afford to update a whole div full of controls (inputs, buttons, labels) just because you did some minor changes to one of them (eg. you turn red all the empty inputs).
A simple $.post or $.ajax call can indeed just retrieve the information and you would just handle it client-side.
精彩评论