2

On file upload, I want ajax hit the url like:

$.ajax(
    { url: '<?php echo base_url();?>apk-reader/ApkInfo.php',
      data: {"apps": "../apps/apk_files/"+file, user_id: "<?php echo $this->session->userdata('user_id'); ?>"},
      type: 'get',
      success: function(output) { alert(output);}

Here I want to store the out put in another variable and use it in OnComplete of another ajax load.

0

3 Answers 3

1

Call other function from success and pass the result to it, SomeFunction(output);

$.ajax({
      url: '<?php echo base_url();?>apk-reader/ApkInfo.php',
      data: {"apps": "../apps/apk_files/"+file, user_id: "<?php echo $this->session->userdata('user_id'); ?>"},
       type: 'get',
      success: function(output) { 
           alert(output);SomeFunction(output)
       }
  });
Sign up to request clarification or add additional context in comments.

Comments

0

you can use this code :

$.ajax({
      url: 'your URL',
      data: {"your Parameter"},
       type: 'get',
      success: function(data) { 
           AjaxMethode(data)
       }
  });

function AjaxMethode(data){
    if(data.d){
        //someCode
    }
}

Comments

0

Declare a variable in global scope and store your output in that varibale. Now you can access the global variable at the callback of any other ajax method,

var result1;
$.ajax( { url: 'apk-reader/ApkInfo.php', data: {"apps": "../apps/apk_files/"+file, user_id: "session->userdata('user_id'); ?>"}, type: 'get', success: function(output) { alert(output);
result1=output;
}
$.ajax( { url: 'apk-reader2/ApkInfo.php', data: {"apps": "../apps/apk_files/"+file, user_id: "session->userdata('user_id'); ?>"}, type: 'get', success: function(output2) { alert(output2);
alert(result1);

}

2 Comments

I would say avoid global variables unless they're necessary. If one function is dependent on the results of another, just pass the results. There's no need to store it globally and access it.
@Yatrix yeah! i agree with you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.