什么更有效 - 使用ASP.NET AJAX或jQuery进行服务器调用?

时间:2021-04-19 13:22:28

I used jQuery exclusively on my last project to do all my AJAX calls. I used both $.ajax and $.getJSON calls to return data to the page. However, I see a ton of examples online using jQuery to handle UI and data formatting, but using ASP.NET AJAX to actually perform web service calls and retrieve data. Is it more efficient to use ASP.NET AJAX to retrieve data for AJAX calls? Does it perform better than jQuery?

我在上一个项目中专门使用jQuery来完成所有的AJAX调用。我使用$ .ajax和$ .getJSON调用将数据返回到页面。但是,我在网上看到大量使用jQuery来处理UI和数据格式化的例子,但是使用ASP.NET AJAX来实际执行Web服务调用和检索数据。使用ASP.NET AJAX检索AJAX调用的数据是否更有效?它比jQuery表现更好吗?

4 个解决方案

#1


9  

I don't think it will make too much difference whether you use ASP.NET Ajax or jQuery. What might make difference is what data is returned and what format it is in i.e. XML, HTML or JSON.

我不认为你使用ASP.NET Ajax或jQuery会有太大的区别。可能有所不同的是返回的数据以及它的格式,即XML,HTML或JSON。

For example, it might be more efficient to return a lightweight JSON object from an Ajax call rather than a big XML document: you can always monitor the size of the Ajax response using Firebug or something similar.

例如,从Ajax调用返回轻量级JSON对象而不是大型XML文档可能更有效:您始终可以使用Firebug或类似方法监视Ajax响应的大小。

You'll probably have to judge each scenario on it's own merits though.

你可能不得不根据它自身的优点判断每个场景。

#2


6  

i used Ajax Control Toolkit from microsoft quite extensively for 2 years before i switched to jQuery and in my experience i think jquery ajax calls are much more light weight, efficient compared to the ajax control toolkit libraries. besides that the efficiency ofcourse depends on the data that you send & receive via your ajax calls.

在我切换到jQuery之前,我使用了来自microsoft的Ajax Control Toolkit 2年,而且根据我的经验,我认为与ajax控件工具包库相比,jquery ajax调用更轻,更高效。除此之外,课程效率取决于您通过ajax调用发送和接收的数据。

you can add custom HTTP Status codes in jQuery ajax calls as well to capture any errors on the server and returning the appropriate response.

您可以在jQuery ajax调用中添加自定义HTTP状态代码,以捕获服务器上的任何错误并返回相应的响应。

#3


1  

I have been wondering this same thing myself. When MS announced JQuery support going forward I was wondering about the "recommended" approach for doing things where the two frameworks overlap (ie: making async calls to the server) going forward since there is some overlap between the two libraries.

我一直想知道同样的事情。当MS宣布JQuery支持向前发展的时候,我想知道两个框架重叠(即:向服务器进行异步调用)的“推荐”方法,因为两个库之间存在一些重叠。

I think the biggest efficiency gain you will get is obviously in the data transport you are using (json vs. xml) but I am not as familiar with JQuery's implementation of $.ajax and $.getJSON versus using something like Sys.Net.WebServiceProxy to call the server. One nice thing about the asp.net ajax client stack is the hooks for network calls, we used this for creating a base behavior that can inspect the response from the server and do something specific (ie: looking for certain HTTP Status codes).

我认为你将获得的最大效率增益显然在你正在使用的数据传输中(json与xml)但我不熟悉JQuery的$ .ajax和$ .getJSON的实现,而不是像使用Sys.Net.WebServiceProxy这样的东西。调用服务器。关于asp.net ajax客户端堆栈的一个好处是网络调用的钩子,我们使用它来创建一个基本行为,可以检查来自服务器的响应并执行特定的操作(即:查找某些HTTP状态代码)。

#4


0  

I thought that ASP.Net's libraries were adapted to use jquery... http://www.aspcode.net/ASPNET-and-JQuery-first-example.aspx

我认为ASP.Net的库适用于jquery ... http://www.aspcode.net/ASPNET-and-JQuery-first-example.aspx

If true, it would mean the two are linked in speed. Although jQueries libraries are likely updated quicker.

如果是真的,那就意味着两者的速度相关联。虽然jQueries库可能更快更新。

#1


9  

I don't think it will make too much difference whether you use ASP.NET Ajax or jQuery. What might make difference is what data is returned and what format it is in i.e. XML, HTML or JSON.

我不认为你使用ASP.NET Ajax或jQuery会有太大的区别。可能有所不同的是返回的数据以及它的格式,即XML,HTML或JSON。

For example, it might be more efficient to return a lightweight JSON object from an Ajax call rather than a big XML document: you can always monitor the size of the Ajax response using Firebug or something similar.

例如,从Ajax调用返回轻量级JSON对象而不是大型XML文档可能更有效:您始终可以使用Firebug或类似方法监视Ajax响应的大小。

You'll probably have to judge each scenario on it's own merits though.

你可能不得不根据它自身的优点判断每个场景。

#2


6  

i used Ajax Control Toolkit from microsoft quite extensively for 2 years before i switched to jQuery and in my experience i think jquery ajax calls are much more light weight, efficient compared to the ajax control toolkit libraries. besides that the efficiency ofcourse depends on the data that you send & receive via your ajax calls.

在我切换到jQuery之前,我使用了来自microsoft的Ajax Control Toolkit 2年,而且根据我的经验,我认为与ajax控件工具包库相比,jquery ajax调用更轻,更高效。除此之外,课程效率取决于您通过ajax调用发送和接收的数据。

you can add custom HTTP Status codes in jQuery ajax calls as well to capture any errors on the server and returning the appropriate response.

您可以在jQuery ajax调用中添加自定义HTTP状态代码,以捕获服务器上的任何错误并返回相应的响应。

#3


1  

I have been wondering this same thing myself. When MS announced JQuery support going forward I was wondering about the "recommended" approach for doing things where the two frameworks overlap (ie: making async calls to the server) going forward since there is some overlap between the two libraries.

我一直想知道同样的事情。当MS宣布JQuery支持向前发展的时候,我想知道两个框架重叠(即:向服务器进行异步调用)的“推荐”方法,因为两个库之间存在一些重叠。

I think the biggest efficiency gain you will get is obviously in the data transport you are using (json vs. xml) but I am not as familiar with JQuery's implementation of $.ajax and $.getJSON versus using something like Sys.Net.WebServiceProxy to call the server. One nice thing about the asp.net ajax client stack is the hooks for network calls, we used this for creating a base behavior that can inspect the response from the server and do something specific (ie: looking for certain HTTP Status codes).

我认为你将获得的最大效率增益显然在你正在使用的数据传输中(json与xml)但我不熟悉JQuery的$ .ajax和$ .getJSON的实现,而不是像使用Sys.Net.WebServiceProxy这样的东西。调用服务器。关于asp.net ajax客户端堆栈的一个好处是网络调用的钩子,我们使用它来创建一个基本行为,可以检查来自服务器的响应并执行特定的操作(即:查找某些HTTP状态代码)。

#4


0  

I thought that ASP.Net's libraries were adapted to use jquery... http://www.aspcode.net/ASPNET-and-JQuery-first-example.aspx

我认为ASP.Net的库适用于jquery ... http://www.aspcode.net/ASPNET-and-JQuery-first-example.aspx

If true, it would mean the two are linked in speed. Although jQueries libraries are likely updated quicker.

如果是真的,那就意味着两者的速度相关联。虽然jQueries库可能更快更新。