2

当我使用 jquery 的 .load() 函数加载一个 html 文件时,它不会像这样加载整个 html:

而不是这个:

<html>
    <head>
        <link .. />
        <script .. />
    </head>
    <body>
        <div>..</div>
        <div>..</div>
    </body>
</html>

它加载这个:

<link .. />

<div>..</div>
<div>..</div>

谁能告诉我为什么以及如果我想加载整个 html 我该怎么办?

4

1 回答 1

-1

Are you

  1. loading the jquery first in the head
  2. loading in the document ready state
  3. have you checked the div name to make sure you are right
  4. use firebug on Firefox as it will show you what is being returned or an error
  5. using load where html is needed

Your code in the head after you have linked jquery should be something like

$(document).ready(function() {
$('#mydivforcontent').load("theforeignpage"); // you may need to replace load with html
});
于 2012-06-07T07:22:19.140 回答