NEW QUESTION. Read the edit for reference of the previous question.
I have this scenario. In the first ajax, I will get an ID from the database and then in the second ajax, I will use this ID.
$(document).ready(function(){
var y = null; // global variable, i guess
function setID(x){
y = x;
}
// Getting the ID
$.ajax({
type: "GET",
url: BASE_URL+'get/new_id',
dataType: "html",
success: function(response){
setID(response);
});
// Using the new ID
$.ajax({
type: "POST",
url: BASE_URL+'save/new_id',
dataType: "html",
data: {id: y}; // using the value from the global variable
// saving ID along with other stuff
success: function(response){
console.log("You have successfully used the new ID");
});
});
This is still my current progress and I haven't finished reading this question. I'm still finding out how to implement the chosen answer there to my question. This is the final state of my question.