如何在循环中发送Ajax请求

时间:2019-10-22 12:08:04

标签: php jquery ajax loops

嗨,我有一个带有html和ajax请求的Php页面。

我正在获取该html数据的屏幕截图,并使用ajax将thar截图保存在服务器上,我的问题是我需要发送该页面的多个屏幕截图而不重新加载,但是html必须根据记录进行更改。

<?php
if(count($users) > 0)
{ ?>

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

HERE IS HTML MUST CHANGE AS PER USER, I CANT RELOAD
THE PAGE AGAIN AND AGAIN AS THIS IS A CRON JOB

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>



<script type='text/javascript'>
function screenshot(){
     html2canvas(document.getElementById('testing')).then(function(canvas) 
{
//document.body.appendChild(canvas);
     // Get base64URL
     var base64URL = canvas.toDataURL('image/jpeg').replace('image/jpeg', 
'image/octet-stream');

     // AJAX request
     $.ajax({
        url: 'ajax/savePNG.php',
        type: 'post',
        data: {image: base64URL, user_id:"<?php echo $valuevb['user_id']; 
 ?>"},
        success: function(data){
           console.log('Upload successfully');
        }
     });
   });
 }
 </script> 

0 个答案:

没有答案