简体   繁体   English

学习AJAX ... VS2010中XMLHttpRequest的替代方法(包装器)是什么?

[英]Learning AJAX… what are the alternatives (wrappers?) for XMLHttpRequest in VS2010?

I am using VS2010 to code against a Microsoft-based ASP.NET server. 我正在使用VS2010对基于Microsoft的ASP.NET服务器进行编码。 And I think that XMLHttpRequest is the foundation of all the AJAX technologies that exist. 而且我认为XMLHttpRequest是所有现有AJAX技术的基础。

Can someone tell me what are the most important wrappers/methods to know about when using Javascript against common technologies? 有人可以告诉我在针对常见技术使用Javascript时需要了解的最重要的包装器/方法是什么? I think I'm getting confused by Microsoft's offering, Google, JQuery, WCF and oData. 我认为我对Microsoft的产品,Google,JQuery,WCF和oData感到困惑。 Not to mention some 3rd party controls seem to offer support as well. 更不用说一些第三方控制似乎也提供支持。

Here is where I get the WCF "wrapper" script from (I think it uses XMLHttpRequest inside) 这是我从中获取WCF “包装器”脚本的位置(我认为它在内部使用XMLHttpRequest)

<asp:ScriptManager ID="ScriptManager1" runat="server">
            <Services>
                <asp:ServiceReference Path="~/GreetingService.svc" />
            </Services>
        </asp:ScriptManager>

jQuery jQuery的

<script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.3.2.min.js" type="text/javascript"></script> 

MS-AJAX MS-AJAX

<script src="http://ajax.microsoft.com/ajax/beta/0909/MicrosoftAjax.js" type="text/javascript"></script>

Can you tell me if all these libraries use XMLHttpRequest internally? 您能告诉我所有这些库是否在内部使用XMLHttpRequest吗? Are there additional scripts I should know about? 我还应该了解其他脚本吗?

My goal is to understand the javascript that hooks into WCF, oData, and any other AJAX-style call to the server. 我的目标是了解与WCF,oData和任何其他AJAX样式的服务器调用挂钩的JavaScript。 Any tips are appreciated! 任何提示表示赞赏!

Thanks! 谢谢!

Jquery ajax should be very good jQuery ajax应该很好

http://api.jquery.com/jQuery.ajax/

You can cross browser calls to .aspx , .asmx and even wcf(svc). 您可以跨浏览器调用.aspx,.asmx甚至wcf(svc)。

We have implemented extensively in Microsfot and jquery compbination for all ajax calls to get data and update data. 我们已经在Microsfot和jquery组合中广泛实现了所有ajax调用,以获取数据和更新数据。

I think jquery goes well with all server side technologies. 我认为jquery与所有服务器端技术都很好。

You can use various return types also like , xml ,json etc. 您可以使用各种返回类型,例如,xml,json等。

Let me know if you need anything else , i will provide more details 让我知道您是否还有其他需要,我会提供更多详细信息

XMLHttpRequest is the object you would use to make some sort of asynchronous call back to send/receive some message. XMLHttpRequest是用于进行某种异步回调以发送/接收某些消息的对象。 However, I think the question you have asked has a few misconceptions. 但是,我认为您提出的问题有一些误解。 gov has provided what is very common and what I use most of the time in my personal projects, which is the jQuery.ajax() method. gov提供了非常常见的内容以及我在个人项目中大部分时间使用的内容,即jQuery.ajax()方法。 This basically wraps up a request for you with a nice, simple syntax. 这基本上是用一种不错的,简单的语法为您包装了一个请求。 There are other libraries out there as well, such as Google Closure, Dojo and YUI(and others!) that do similar abstractions, depending on what you need. 还有其他库,例如Google Closure,Dojo和YUI(以及其他!),它们根据您的需要进行类似的抽象。

I'm assuming by Microsoft's offering, you mean using UpdatePanels. 我以微软的产品为假设,您的意思是使用UpdatePanels。 This will basically simulate an asynchronous callback, however it will still use the postback methods you may be accustomed to. 这基本上将模拟异步回调,但是仍然会使用您可能习惯的回发方法。 I personally haven't gone this route, because I like to control the javascript being used on the page(as opposed to Microsoft's generator). 我个人没有走这条路,因为我喜欢控制页面上使用的javascript(而不是Microsoft的生成器)。

WCF is really for create services that can consume or provide messages. WCF实际上是用于创建可以使用或提供消息的服务。 It's possible you would like to call a WCF service with your ajax method, however, WCF on it's own doesn't do anything ajaxy. 您可能想使用ajax方法调用WCF服务,但是,WCF本身并没有做任何ajaxy。

I haven't worked with oData personally, but from what I can tell, it's a service protocol to help structure messages coming back across the wire, via atom or json feeds. 我还没有亲自使用过oData,但据我所知,这是一种服务协议,可帮助通过原子或json提要来构造通过电线返回的消息。

The simplest and quickest stack I can see in this scenario would be utilizing jQuery to talk to an asmx page. 在这种情况下,我能看到的最简单,最快的堆栈就是利用jQuery与asmx页面对话。 If you haven't written in WCF yet, get ready for the fun of configuration! 如果您尚未编写WCF,请准备好进行配置的乐趣! I hope any of the above information helps you along. 希望以上任何信息对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM