I am just picking up on using jquery and have managed to put the .ajax function into use to retrieve an an html page.
Now, the retrieved html page has a link to a css file and I want to grab that as well so that when the page is loaded, the css will be in the cache as well.
So my question essentially is that is it possible to run another ajax call as the success function and if so, is the config I am thinking of using (see code below) on the right track?
$(window).load(function(){
var ourPath;
$('head link[rel="id_tag"]')
.each(function() {
ourPath = $(this).attr('href');
$.ajax({
url: ourPath,
dataType: 'html',
ifModified: true,
success: function (html) {
var dataURL;
$(html).find('link[rel="stylesheet"]')
.each(function() {
dataURL = $(this).attr('href');
$.ajax({
url: dataURL,
dataType: 'text',
ifModified: true
});
});
}
});
});
});
I am particularly unsure about the $(html).('head link[rel="stylesheet"]'); and dataURL = $(this).attr('href'); lines (assuming the whole idea is feasible in the first place)
Coming back to update this.
What actually works reliably is:
The key is
$(html).filter('link[rel="stylesheet"]')in place of the suggested$(html).find('link[rel="stylesheet"]').The input given helped lead to the solution nonetheless.