Jaime Rodriguez On Windows Phone, Windows Presentation Foundation, Silverlight and Windows 7
Last post we did a REST call using XmlHttp from a sidebar gadget... but let's admit it, we were all doing xmlhttp calls in 2000 and we were 'geeks'... it was not until 2005? that this exact same code became "cool" because it was called AJAX ... So here is the ticket to get you to the cool group -- every one knows I will never make that :(
Pre-requisites (or stuff you get with the sample code located here)
The client code:
The trick: Atlas by default uses frames to get around cross-site scripting...
OK, I think that is all we needed... we are now ready to party w/ ajax.. :) To run the sample, simply click in the button in the gadget...
WHY BOTHER using Atlas to call webservices instead of just plain old XmlHttp like we did on my last post??... Well, there is one nice reason to do this: Atlas does some nice JSON serialization on the back-end and front-end, so the results come back as objects instead of as an XML file you need to parse... for example, my webservice returns an object... that looks like this in C#:
/*digress: why this weird object I started with a simple Echo function ... that returned what you sent.. but then I decided to do a more complex object .. so I thought an echo would do... here you get the echo at 10m ( LOUD ) at 50m ( LOud) and at 100m when it fades (loud) .... you can stop gagging now :) */
The code for this sample is located here, there is a client side component ( sample.gadget) and a server side component ( AtlasWS ) ... You will as usual have to change the URLs in AtlasServiceProxy.js from pointing to my servers to pointing to yours..
Para deixar registrados, dois artigos legais sobre criação de Gadgets : Gadget Development...
Για όσους ενδιαφέρονται να δούνε σε μεγαλύτερο βάθος τα Vista Gadgets έχω μαζέψει κάποιο αρκετά βοηθητικό