.load() メソッドのドキュメントといくつかのオンライン リソースを読みましたが、作成中のアプリでは機能しません。以前に .load を使用したことがないことに注意してください。
<script type="text/javascript">
$(document).ready(function() {
$('#next').click(function(e){
alert("Click"); // this alerts when clicked as expected
$('#atestimonial').load('testimonial.php', function() {
alert('Load was performed.');
});
return false;
});
});
</script>
イベントは意図したとおりに機能します。そのコード ブロックは header.php (wordpress を使用) にあり、実際の div #testimonial は sidebar.php にあるため、別のファイルにあります。これは問題ですか?
testimonial.php の内部は次のとおりです。
<?php
include('testimonialPull.php');
echo "Bahh";
?>
testimonialPull.php
<?php
require_once('../../../wp-blog-header.php');
query_posts(array(
'cat' => 4,
'order' => 'ASC', // ASC
'orderby' => 'rand',
'showposts' => 1,
));
$wp_query->is_archive = true; $wp_query->is_home = false;
if (have_posts()) : while (have_posts()) : the_post();
the_content();
endwhile; endif;
?>
testimonialPull の内容を削除すると、正しくエコーされます。
これは、証明書の div にランダムな投稿を取得するだけです。
実際の div とボタンの構造は次のとおりです。
<div id="testimonials">
<div class="tHeading"><h4>Client Testimonials</h4></div>
<div class="atestimonial">
<?php
include('testimonial.php');
?>
</div>
<div id="next"><a id="nextC" href="#" return="false">NEXT TESTIMONIAL</a></div><!-- END #next -->
</div><!-- END #testimonials -->
それで、.load を使用して div に証言が表示されないようにするために何か間違ったことをしましたか?
これを読んでいただきありがとうございます。
高速編集
これは localhost で動作しています。これは localhost では機能しないと読みましたが、これは正しいですか?