Tag: Ajax

Through long-available browser quirks/features, javascript has been available for requests across disparate domains. But, other resources, such as text files (eg, handlebars templates) have had more restrictions placed on them. Recently, CORS support has enhanced the ability to make these requests. Here’s how you get your text files from another domain via requirejs.

Don’t you hate developing a blasted simple webpage that does some asynchronous requests that gets you into cross-origin policy trouble. If you just read a .html file off the file system, this will bite you. But, it’s easy to get around. Just host your .html file on a simple http server. And it’s easy to make that happen. Here’s one way.

BackboneJS is setup to do some pretty sweet single-page app action. And of course, a single page app will probably be wanting to talk to web services on the server. And if your server code is doing the Java jive, then a great way to expose your REST services is via JAX-RS. It’s as easy as Mikey singin’ ABC-123!

Jquery, Ajax, Json, Django – this is quite a laundry list of technologies. In fact, it’s pretty much the whole stack: client tech, server requests, over-the-network data format, and a backend app server. In the following slidedeck and example code, we’re going to touch on the whole stack and not get too deep into any one area. By the end, you should be able to at least have a grasp of what technologies one can use in an Ajax Django application, a little bit of what they’re capable of, and then, hopefully, a list in your brain that you can go back, reference, and then drill into specific technologies when you want to go build something similar yourself.

Jquery gives a great, easy-to-use mechanism for extending its API and creating your own plugins. For stuff that looks like it could be useful generally, you should really try to put it into a nice little plugin package. For submit buttons, there is a general thought that they shouldn’t be clicked twice (especially for functions such as financial transactions), so I created a plugin that fits an app that I have been working on recently, where there are many, many submit buttons, saving very granual pieces of content through ajax requests.

Have you ever had a problem with ajax requests caching in Internet Explorer. I have, and recently I came across a nicer solution than I have traditionally used. In the past, I have used a unique parameter on the url to keep IE from caching previous requests to the same url, like so: