开发者

Learning AJAX... what are the alternatives (wrappers?) for XMLHttpRequest in VS2010?

I am using VS2010 to code against a Microsoft-based ASP.NET server. And I think that XMLHttpRequest is the foundation of all the AJAX technologies that exist.

Can someone tell me what are the most important wrappers/methods to know about when using Javascript against common technologies? I think I'm getting confused by Microsoft's of开发者_运维问答fering, Google, JQuery, WCF and 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)

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

jQuery

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

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? 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. Any tips are appreciated!

Thanks!


Jquery ajax should be very good

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

You can cross browser calls to .aspx , .asmx and even wcf(svc).

We have implemented extensively in Microsfot and jquery compbination for all ajax calls to get data and update data.

I think jquery goes well with all server side technologies.

You can use various return types also like , xml ,json etc.

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. 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. 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.

I'm assuming by Microsoft's offering, you mean using 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).

WCF is really for create services that can consume or provide messages. 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.

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.

The simplest and quickest stack I can see in this scenario would be utilizing jQuery to talk to an asmx page. If you haven't written in WCF yet, get ready for the fun of configuration! I hope any of the above information helps you along.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜