weixin_33693070 2016-03-21 10:06 采纳率: 0%
浏览 37

在Ajax中使用PHP函数

I am trying to get to run a php loop once i press on a radio button. I realize that i have to do this using ajax. I am very new to ajax so im having a hard time getting this done. What happens now is that i cannot even press the radio button anymore and nothing shows up.

what i tried so far:

my loop(which works fine): magazines.php:

<?php
$args = array( 'post_type' => 'magazine', 'posts_per_page' => 10 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
  the_title();
  echo '<div class="entry-content">';
  the_content();
  echo '</div>';
endwhile;
}
?>

Ajax in main page:

$('radio').click(function() {
$.ajax({
    url: 'magazines.php',
    success: function(){
         alert('success');
    }
});

return false;
});

Any help would be appreciated. Thanks!

  • 写回答

4条回答 默认 最新

  • weixin_33724659 2016-03-21 10:09
    关注

    Try this

    $('body').on('click','input:radio',function() {
        $.ajax({
          url: 'magazines.php',
          success: function(data){
            $('#your-selector').html(data);
          }
          });
    })
    
    评论

报告相同问题?

悬赏问题

  • ¥15 三菱变频器模块怎么检测触发
  • ¥15 在C#方法中使用了.Refresh();刷新了控件,但是不是最新值
  • ¥30 求一下解题思路,完全不懂。
  • ¥30 关于#硬件工程#的问题:求一下解题思路
  • ¥15 运筹学对偶单纯行法构造扩充问题
  • ¥20 XP系统的老电脑一开机就提示找不到rundll.exe,付费求解
  • ¥15 milvus查询出来的score怎么转换成0-1之间的相似性
  • ¥15 lvgl V9移植到linux开发板
  • ¥15 VB.net中在窗体中创建一个button控件来关闭窗体,但是提示错误,我该怎么办
  • ¥15 网上下载好的程序但是arduinoIDE编程报错,运行不了,哪里出错了,能具体给改一下吗