I have been using the fantastic jQuery library for quite some time and have become familar with its AJAX capabilities. I am working on a project which only requires the AJAX capabilities of jQuery. Separating this logic from jQuery is not so easy because there are so many dependencies.
I need an AJAX library which can achieve the following (in the same way that jQuery allows):
- Load script from another domain
- Load script from same domain
- Execute callback as soon as script has been executed
Using jQuery this can be achieved easily using:
$.ajax({
type : 'GET',
url : url,
dataType : 'script',
cache : true,
success: function() {
// script has literally just finished executing...
}
})
Which well established (and lightweight) open source library would achieve these requirements?
Okay, it turns out that the functionality that I require is not truly part of an AJAX response. Looking in the jQuery source I found that the “script” handler is essentially creating a “script” element temporarily and then removing it once it has loaded.
Link to relevant jQuery source:
https://github.com/jquery/jquery/blob/master/src/ajax/script.js
The following page describes this process in greater detail:
http://www.ejeliot.com/blog/109