There may be cases where you want to download the whole audio file before loading it into the HTML5 Audio widget.

In my case, while it is easy to just set the URL to the source of the HTML5 Audio widget, it does not work if the URL is cross-domain.

Downloading the whole binary was the only solution that I came up with.

This can be done using plain Javascript. With JQuery however, there seems to be no way to do this because AJAX calls return a response type of string. Using traditional Javascript is no problem anyway.

See following code:

That’s it!

The solution is simple if you know which function to call. I had read so many suggestions, some long, some a hassle when in fact, the quickest and shortest solution to execute code after all Ajax requests are finished in JQuery is this:

Easy, right?

So what is with a little Javascript library, right? Even though it is not hard work to go around to using forms in Javascript, using JQuery Form plugin enables me to gain access to my form after simple Ajax calls.

The main methods, ajaxForm and ajaxSubmit, gather information from the form element to determine how to manage the submit process. Both of these methods support numerous options which allows you to have full control over how the data is submitted.

Their site says it is extremely useful for sites hosted in low cost web hosting providers with limited features and functionality. But even so, JQuery‘s simplistic approach and flexibility created this awesome plugin that enabled me not to have to code on doing Ajax calls the traditional way.

Say, you have this HTML form.

Simply initialize your form when the DOM is ready. Once the form is submitted, you can get what is returned from the server. Easy, right?!

Related Posts Plugin for WordPress, Blogger...