Problem with making multiple ajax calls with timing

am having problem, i want to make 2 ajax calls with timing, but i think the problem is with timing, because i want to call other post when 10 seconds has passed

$(document).ready(function () {
 $("#button2").click(function(event) {
       Execute();
    });


    $.ajax({
        type: 'POST',
        url: 'ezm.php',
        data: { 
		        'email': $("input[name='email']").val() 
				},
				
		beforeSend: function(){ 
        
		if ($("form input[name='email']").val() == "") {
        $('#error').text('no email');
		return false;
		}    
		},
		
		complete: function(){
		 $('#error').hide();
		 },
		 
         success: function(res) {
    $('#result').html(res.msg);
  },
  
  error: function() {
          alert("failed");
        },
             
        setTimeout(function(){
           
           },10000);
      });
	  
	  // call this section when 10 seconds has passed 
    $.ajax({
    type: 'POST',
    url: 'ezt.php',
    success: function(resp) {
     $('#result2').text(resp.info);
  },
        error: function() {
          alert("failed");
        }
        });
	
});

If you want that, you should to place your second AJAX call in setTimeout function. Otherwice you will get two AJAX calls and then nothing in 10 seconds.

i will be happy if there some demonstration

Your second call…

function send2()
{
    $.ajax({
        type: 'POST',
        url: 'ezt.php',
        success: function(resp) {
            $('#result2').text(resp.info);
        },
        error: function() {
            alert("failed");
        }
    });
}

Your setTimeout…

setTimeout(send2,10000);
1 Like

this is not working, where to place setTimeout., can provide full code snap instead breaking into parts. its hard to understand