I am using the jQuery (1.7.2) getScript() AJAX method to fetch an external (cross-domain) HTML page which contains embedded javascript. I am using the 'script' data type for the getScript() command because it has no cross-domain restrictions. In the browser's JS console, I use the following code which is equivalent to a getScript() request:
$.ajax({
url: url, // This url is for an HTML page with embedded JS - not for a JS file
type: 'get',
crossDomain: true,
dataType: 'script',
beforeSend: function(result) { result.setRequestHeader('Accept', '*/*') },
success: function(result) { console.log('SUCCESS:\t' + result) },
error: function(result) { console.log('ERROR') },
complete: function(result) { console.log('COMPLETE:\t' + result.responseText) }
})
This returns with 'success', but no result.
SUCCESS: undefined
COMPLETE: undefined
The console also tells me that the content was interpreted as a script but transferred with MIME type text/html (I suppose this is because the url I'm using is for an HTML page). I know the entire HTML data was transferred to the client because I can access it using the browser JS console's network panel, and I can confirm that the correct number of KBs was indeed transferred.
I'm not sure I'm concerned about the MIME message because I really just need to get my hands on the transferred content and do some parsing. How can I access this transferred content - which is somewhere on the client side - using jQ/JS? If I can't get to it, how is it that the browser console's network panel has access to it?