HTML and CSS Reference
In-Depth Information
_script.src = _src;
* To prevent the script from blocking other requests, load it
* asynchronously where possible
_script.async = "async";
* Once the script has loaded, the function will execute and the
* script tag can be removed from the head of the document
_script.onload = _script.onreadystatechange = function(load){
var script = document.head.removeChild(;
script = null;
* This privileged method will send the request by appending the script to
this.send = function(){
The utility itself isn't very complicated. It simply creates a script element and
embeds it into the document. After the script has finished loading, the onload
event listener will automatically remove it from the DOM.
To make a request, it's as simple as calling.
var request = new app.utility.jsonp(“”,
The problem with JSONP is that unlike Ajax, you can't cancel a request. So if
you are sending requests frequently for an autocomplete field, you may find that
several requests are sent, but they do not come back in the order that you
expect. How to handle this will be covered in the Movies Controller further into
this chapter.
Search WWH ::

Custom Search