load() PHP 在元素之后
load() PHP after element
因为某些原因我需要通过jquery加载一个PHP文件(在最后一点它将负责调用wordpress动态侧边栏但我无法在里面执行php jquery)。我现在拥有的是:
$('#pa_kategoria-cenowa').after('<div class="product-variation-desc"><div id="5" class="box">CENA 5 - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean semper egestas sodales. In commodo massa eget lectus eleifend, nec dictum sapien laoreet. </div><div id="10" class="box">CENA 10 - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean semper egestas sodales. In commodo massa eget lectus eleifend, nec dictum sapien laoreet. </div><div id="15" class="box">CENA 15 - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean semper egestas sodales. In commodo massa eget lectus eleifend, nec dictum sapien laoreet. </div></div>');
我的php文件被调用:load-widgets.php
这就是加载函数应该看起来像这样的原因:
.load('load-widgets.php');
PHP 文件的内容如下:
<div class="product-variation-desc"><div id="5" class="box">CENA 5 - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean semper egestas sodales. In commodo massa eget lectus eleifend, nec dictum sapien laoreet. </div><div id="10" class="box">CENA 10 - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean semper egestas sodales. In commodo massa eget lectus eleifend, nec dictum sapien laoreet. </div><div id="15" class="box">CENA 15 - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean semper egestas sodales. In commodo massa eget lectus eleifend, nec dictum sapien laoreet. </div></div>
但我不知道如何将它们组合在一起。我试过:
$('#pa_kategoria-cenowa').after().load('load-widgets.php');
但它不起作用。如何实现?
您现有的代码应该可以工作。检查控制台中的错误。如果仍未解决,请尝试以下 AJAX 代码段。
$.get("load-widgets.php", function(data){ // Loads content into the 'data' variable.
$("#pa_kategoria-cenowa").after(data);
});
因为某些原因我需要通过jquery加载一个PHP文件(在最后一点它将负责调用wordpress动态侧边栏但我无法在里面执行php jquery)。我现在拥有的是:
$('#pa_kategoria-cenowa').after('<div class="product-variation-desc"><div id="5" class="box">CENA 5 - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean semper egestas sodales. In commodo massa eget lectus eleifend, nec dictum sapien laoreet. </div><div id="10" class="box">CENA 10 - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean semper egestas sodales. In commodo massa eget lectus eleifend, nec dictum sapien laoreet. </div><div id="15" class="box">CENA 15 - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean semper egestas sodales. In commodo massa eget lectus eleifend, nec dictum sapien laoreet. </div></div>');
我的php文件被调用:load-widgets.php
这就是加载函数应该看起来像这样的原因:
.load('load-widgets.php');
PHP 文件的内容如下:
<div class="product-variation-desc"><div id="5" class="box">CENA 5 - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean semper egestas sodales. In commodo massa eget lectus eleifend, nec dictum sapien laoreet. </div><div id="10" class="box">CENA 10 - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean semper egestas sodales. In commodo massa eget lectus eleifend, nec dictum sapien laoreet. </div><div id="15" class="box">CENA 15 - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean semper egestas sodales. In commodo massa eget lectus eleifend, nec dictum sapien laoreet. </div></div>
但我不知道如何将它们组合在一起。我试过:
$('#pa_kategoria-cenowa').after().load('load-widgets.php');
但它不起作用。如何实现?
您现有的代码应该可以工作。检查控制台中的错误。如果仍未解决,请尝试以下 AJAX 代码段。
$.get("load-widgets.php", function(data){ // Loads content into the 'data' variable.
$("#pa_kategoria-cenowa").after(data);
});