0

I'm trying to run two jquery ajax methods using post, the first step, submits the request, and returns job id, the second step should take the job id and pass it into another ajax function, I have tried the following, but passing the value to step 2, doesn't seems to work.

$(document).ready(function(){

  $("button").click(function(){

   // Step1: send request to cs1.php and return job id

    $.get("cs1.php",function(data){

      var jobid = data; 

      alert(jobid); // this works and returns job id

   // Step2: use job id returned from step1 here     

     $.post('process.php', {jobid: jobid}, function(data) {

        $('#div1').text(data);
  });

    });
  });
});

</script>

Your help is highly appreciated.

Deano
  • 11,582
  • 18
  • 69
  • 119
  • Explain "doesn't seem to work". Have you checked the cosole? Or network tab to check the headers that are being sent? – Kamran Ahmed Nov 14 '14 at 03:58
  • Try to use synchronous ajax call(sjax)...http://stackoverflow.com/questions/5821380/how-to-make-a-jquery-post-request-synchronous – amit_183 Nov 14 '14 at 04:35

0 Answers0