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条回答 默认 最新

    报告相同问题?