我希望做一些innerHTML的替代品,但使用PHP包括,我不明白怎么样。我已经做的innerHTML替换之前,只是没有用PHP。
I want to do some innerHTML replacements, but using PHP includes, I dont get how. I have done innerHTML replacements before, just not with PHP.
我有:
var xmlHttp
function DisplayAerialProductListing()
{
var strStartCode="<p></p>";
document.getElementById("txtData").innerHTML= strStartCode;
var code="";
code = code + "<?php include 'newpage.inc'; ?>";
document.getElementById("txtData").innerHTML= code;
}
我有'txtData'股利如下:
I have the 'txtData' Div as:
首先,我想,以取代从。公司我提到的code。我使用。公司分离出该网站的作品,并作出这样方便设计师,使他们不去打破的东西!
initially and I want to replace with code from the .inc I mention. I use .inc to separate out pieces of the site and to make like easier for the designer so they dont go breaking stuff!
在。公司我只是HELLO现在。
In the .inc I just have HELLO for now.
这是行不通的。什么是成功?
It doesn't work. What is the trick?
推荐答案
使用 jQuery的,你可以钉,几乎毫不费力地:
Using jQuery, you can nail that almost effortlessly:
<p id="myParagraph"></p>
<script>
//when the DOM is ready
$(document).ready(function() {
//replace contents of p id="myParagraph" with output of specified script
$('#myParagraph').load('myPage.php');
});
</script>
不过,请确保您了解客户端和服务器之间的差异为每@ DAV的答案。
Still, make sure you understand the difference between client and server as per @Dav's answer.
请参阅 http://docs.jquery.com/Ajax
相关推荐
最新文章