Pages Menu
TwitterRssFacebook

Posted by on Jan 30, 2011 in Development

AJAX with jQuery

This is one of a set of notes for talks I attended as part of DeveloperDeveloperDeveloper9, held at Microsoft Reading on 29th January 2011. They are mostly for my own records, but if you find them useful, good. If you have any questions about the content (unless it’s to tell me I’m irresponsibly wrong), I’d suggest contacting either the speakers or someone who knows more about the content than I do! You can also see the twitter hashtag timeline of the day – #ddd9.

Title: AJAX with jQuery

Speaker: George Adamson
@GeorgeAdamson

Slides: tba

Useful links:
api.jquery.com
jqueryui.com

Notes:
using .live to clone objects instead of .clone will create them ‘evented’ children – i.e. their events will bubble up and be caught by their parent. Otherwise .clone’d objects are dead (no events)

Can Hijax links by catching onClick event and loading html into DIVs. Can utilise this to create tabs.

Really useful command getJSON – fetches JSON into the page. Takes URL and callback function.
getJSON works if you are accessing a JSON server on your domain, but if you access any other server, will get Cross Domain errors.
So, instead, use JSONP. (JSON with padding). The reason that JSON doesn’t work across domains is that although you can download images and event scripts from other sites, you can’t download perfectly safe text html. JSONP takes results of JSON statement and wraps it into a function call. Once it comes back, you can then use json.results.  (You need to be accessing a server that understands JSONP to do this. Facebook and the big ones do)
To use JSONP, add &callback=? to the URL string. If you check firebug you can see this happening.

YQL – Yahoo Query Language. Worth a look.

Written by Tom Morgan

Tom is a Microsoft Teams Platform developer and Microsoft MVP who has been blogging for over a decade. Find out more.
Buy the book: Building and Developing Apps & Bots for Microsoft Teams. Now available to purchase online with free updates.

Post a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.