在php ajax循环中计算20秒并返回结果

在php ajax循环中计算20秒并返回结果,php,ajax,Php,Ajax,我有一个php和ajax脚本 $.post(ajaxurl, data, function(response) { if(response == 0){ $('.fetchresults').show(); $('.fetchresults').html('<button type="button" class="btn close">x</button>No

我有一个php和ajax脚本

         $.post(ajaxurl, data, function(response) {
               if(response == 0){
                $('.fetchresults').show();
                $('.fetchresults').html('<button type="button" class="btn close">x</button>No new podcast posts added.</div>');           
                $('.fetchresults').fadeIn('fast');
                } else {
                $('.fetchresults').show();
                $('.fetchresults').html('<button type="button" class="btn close">x</button>' + response + ' new podcasts posts added.</div>');            
                $('.fetchresults').fadeIn('fast');

                } 
           });
然后在foreach循环中获取结果,然后插入到wordpress帖子中

有时表中的记录太多,服务器执行超时,有时会卡住

我只想数20秒,然后返回ajax结果,然后自动调用ajax


这可能吗?

所以我假设您在服务器上执行脚本的最长时间是20秒,对吗。为什么不成批处理固定大小的表,这些表肯定会在20秒内处理完毕。然后一个接一个地处理每一批?你能解释更多的编码吗?
          $podcast_items = $wpdb->get_results("SELECT * FROM " . $table_spp_podcast );