jQuery vs . ASP中的MicrosoftAjax。NET MVC

时间:2023-01-21 03:22:21

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

在什么情况下,您会在ASP中使用MicrosoftAjax胜过jQuery。净MVC应用程序?

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.

根据Scott Cate在这个播客面向对象的AJAX与Scott Cate MicrosoftAjax的好处是发送和检索数据到和从服务器。jQuery很适合在数据到达客户端后通过DOM进行操作。但是,使用jQuery简单的表单插件,您可以很容易地使用jQuery发送和检索数据。通常只有一行代码。

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

所以我想知道在ASP中,MicrosoftAjax和jQuery之间有什么区别。净MVC吗?

4 个解决方案

#1


14  

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.

使用jQuery——就连微软也看到了他们的错误。Visual Studio的下一个版本将包含jQuery并支持它的intellisense。关于这个简单的插件,您也完全正确。阿贾克斯女士虽然在最初的时候更容易处理,但是她的行动缓慢而且臃肿。

#2


2  

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

我试着把两者或多或少地同时使用。

The builtin ajax helpers works fine.

内置的ajax助手运行良好。

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

但是jquery的占用空间更小,使用起来更加透明。

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

当使用ajax助手时,我得到了即时的结果,但没有意识到幕后发生了什么。

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

此外,如果为了扩展ajax场景,您必须过渡到jquery,那么您最好从这里开始。

#3


0  

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.

jQuery重量更轻,更容易集成到标准的javascript函数中,并且具有很好的社区支持。Ajax很重,但是我怀疑他们重写了Ajax。

#4


0  

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

一定要使用jQuery。ajax函数,而不是jQuery。get -它更加冗长,但是对于错误处理是至关重要的。

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.

不要仅仅因为jQuery.get()更容易就忽略错误处理代码。它可能在您的测试中发挥作用,但是您需要对它无法工作的许多情况进行某种错误处理。

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

我真的不确定为什么get没有错误处理,但是这里有一个来自于get的jQuery文档的引用:

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.

这是向服务器发送简单GET请求而无需使用更复杂的$的简单方法。ajax功能。它允许指定一个回调函数,该函数将在请求完成时执行(并且只有在响应具有成功的响应代码时)。如果您需要同时具有错误和成功回调,您可能需要使用$.ajax。

#1


14  

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.

使用jQuery——就连微软也看到了他们的错误。Visual Studio的下一个版本将包含jQuery并支持它的intellisense。关于这个简单的插件,您也完全正确。阿贾克斯女士虽然在最初的时候更容易处理,但是她的行动缓慢而且臃肿。

#2


2  

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

我试着把两者或多或少地同时使用。

The builtin ajax helpers works fine.

内置的ajax助手运行良好。

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

但是jquery的占用空间更小,使用起来更加透明。

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

当使用ajax助手时,我得到了即时的结果,但没有意识到幕后发生了什么。

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

此外,如果为了扩展ajax场景,您必须过渡到jquery,那么您最好从这里开始。

#3


0  

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.

jQuery重量更轻,更容易集成到标准的javascript函数中,并且具有很好的社区支持。Ajax很重,但是我怀疑他们重写了Ajax。

#4


0  

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

一定要使用jQuery。ajax函数,而不是jQuery。get -它更加冗长,但是对于错误处理是至关重要的。

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.

不要仅仅因为jQuery.get()更容易就忽略错误处理代码。它可能在您的测试中发挥作用,但是您需要对它无法工作的许多情况进行某种错误处理。

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

我真的不确定为什么get没有错误处理,但是这里有一个来自于get的jQuery文档的引用:

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.

这是向服务器发送简单GET请求而无需使用更复杂的$的简单方法。ajax功能。它允许指定一个回调函数,该函数将在请求完成时执行(并且只有在响应具有成功的响应代码时)。如果您需要同时具有错误和成功回调,您可能需要使用$.ajax。