dougan1330 2016-04-03 14:25
浏览 183

AJAX响应页面:CSS丢失了一部分?

I'm wondering how I could attach CSS and JS into my sidebar. The sidebar is part of the bootstrap UI and has JS and CSS in it.

Sidebar has slide-down- menus built of li-elements and links. Naturally it worked well before ajax.

File lists2.php has 50% of it php assembyling arrays and the rest just echoes the arrays into special drop-down menus and links.

The ajax tries to change contents of the sidebar div of index.php: index has the same css- and js-files in it so they should have the same files. But I understood that the resulting data of ajax is in different scope than index.php.

I already tried: - Including css- and js-files in the lists2.php - Trying to append at least single css-file in the ajax, as you see below - And some other things I dont even remember anymore

This should be basics, but how can I figure it out?

Thanks a lot.

$(document).ready(function() {
  $.ajax({
    method: "GET",
    url: "lists2.php",
    cache: false,
    dataType: "html",
    beforeSend: function() {
      $(".sidebarcontent").text("Loading..");
    },
    success: function(lists) {
      $(".sidebarcontent").html(lists);
      $("head").append('<link href="style.css" rel="stylesheet">');
    }
  });
});

</div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥15 c++头文件不能识别CDialog