Javascript 使用php foreach的Jquery.text()
我想在div中动态显示一些内容。 这个内容来自我在php中的一个函数 你知道我该怎么做吗 HTML:Javascript 使用php foreach的Jquery.text(),javascript,php,jquery,Javascript,Php,Jquery,我想在div中动态显示一些内容。 这个内容来自我在php中的一个函数 你知道我该怎么做吗 HTML: JQUERY: $(".creativeSecondField > div.secondFieldContent").text(""+ <?php $info+this.id = $this->sqlCategories+this.id; foreach ( $info+this.id as $valuesinfo+this.id ) {
JQUERY:
$(".creativeSecondField > div.secondFieldContent").text(""+
<?php
$info+this.id = $this->sqlCategories+this.id;
foreach ( $info+this.id as $valuesinfo+this.id )
{
echo $valuesinfo+this.id['designation_en'];
}
?>
+"");
$(“.creativeSecondField>div.secondFieldContent”).text(“”+
+"");
首先创建一个php页面,返回动态内容,如
getContent.php
<?php
echo "hello";
?>
之后,在希望使用jquery显示动态内容的页面上,执行以下操作
<div class="creativeSecondField">
<h1 class="secondFieldTitle"></h1>
<div class="secondFieldContent"></div>
</div>
<script>
$(document).ready(function() {
$(".secondFieldTitle").load("getContent.php");
});
</script>
$(文档).ready(函数(){
$(“.secondFieldTitle”).load(“getContent.php”);
});
使用它谢谢你……这段代码真的对你有用吗?@true不是真的:(但我不知道创建页面时PHP在服务器上运行有什么错误。它无法在页面发送到浏览器后动态更新页面。PHP无法访问像
this
这样的Javascript变量。您需要了解PHP和Javascript之间的关系。它无法工作。this.id
是PHP的税务错误。
<div class="creativeSecondField">
<h1 class="secondFieldTitle"></h1>
<div class="secondFieldContent"></div>
</div>
<script>
$(document).ready(function() {
$(".secondFieldTitle").load("getContent.php");
});
</script>