New Ajax call as Ajax success function

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)
$(this).attr('href') === this.href

以上就是New Ajax call as Ajax success function的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » jQuery 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏