Ajax Content Type Handling in jQuery

Before jQuery 1.4, you had to specify the dataType in all of the types of ajax requests.

$.get(url, data, function, "html/json/xml..");
$.post(url, data, function, "html/json/xml..");
 dataType: "html/json/xml.."

Now, you can have the server respond with the mime type like application/json and jQuery will automatically switch the dataType for you! This makes more sense because the server is the one sending the response, jQuery is only handling it.

Continue Reading »

Building HTML in jQuery and JavaScript

It can be a pain to create HTML elements in JavaScript. In this article I will outline a few ways I deal with HTML. First, we’ll look at whether to use an HTML string or a jQuery object, then look at my little HTML string builder utility and finally get some links to templating libraries for building more complex HTML.

Continue Reading »