jQuery vs MicrosoftAjax in ASP.NET MVC

99封情书 提交于 2019-12-09 05:27:45

问题


Under what circumstances would you use MicrosoftAjax over jQuery in an ASP.NET MVC application?

According to Scott Cate in this podcast Object Oriented AJAX with Scott Cate MicrosoftAjax is good for sending and retrieving data to and from the server. And jQuery is good for manipulating your data via the DOM once it arrives at the client. Yet, with a simple form plugin for jQuery you can send and retrieve data with jQuery quite easily. Often with a single line of code.

So I'm wondering what the difference is between MicrosoftAjax and jQuery within ASP.NET MVC?


回答1:


Go with jQuery - even Microsoft has seen the error of their ways. The next version of Visual Studio will include jQuery and support it with intellisense. You're also entirely correct regarding the simple plugin. MS Ajax, while sometimes easier to work with initially, is slow and bloated.




回答2:


I have tried to use both more or less side by side.

The builtin ajax helpers works fine.

But jquery has a smaller footprint and is more transparent in use.

And when using the ajax helpers I get immediate results but no sense of what goes on behind the scenes

Besides If you have to bridge over into jquery in order to extend your ajax scenario, you might as well start there.




回答3:


jQuery is lighter-weight, easier to integrate into standard javascript functions, and has great community support. MS Ajax is heavy, but I suspect they are rewriting everything AJAX.




回答4:


Just be sure to use the jQuery.ajax function and not jQuery.get - its more verbose, but vital for error handling.

Don't skimp on error handling code just because jQuery.get() is easier. It may work on your tests, but you need some kind of error handling for the many cases it wont work.

I'm really not sure why get doesn't have error handling, but here's a quote from the jQuery documentation for get:

This is an easy way to send a simple GET request to a server without having to use the more complex $.ajax function. It allows a single callback function to be specified that will be executed when the request is complete (and only if the response has a successful response code). If you need to have both error and success callbacks, you may want to use $.ajax.



来源:https://stackoverflow.com/questions/492770/jquery-vs-microsoftajax-in-asp-net-mvc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!