jQuery ajax call does not launch callback when data type is 'script'

595 Views Asked by At

For example with jQuery 1.5.2 or smaller this code will log 'ololo' in FireBug console:

$.get(
'some_url', 
{ data: 'some_data' }, 
function() { 
   console.log('ololo') 
}, 
'script')

Same with .ajax (any type of request), .post

But with jQuery 1.6-1.6.1 the callback does nothing. However, the callback will be launched if data type is anything except 'script'. For example, 'json' or 'html.'

I have not been able to find something concerning this on http://api.jquery.com/jQuery.get/

1

There are 1 best solutions below

0
On

I think the "script" datatype makes jquery behave like getScript() which

Load a JavaScript file from the server using a GET HTTP request, then execute it.

To me that means that no callback will be called, as the script will be executed.