Hi guys I am having a issue in terms of using ajax call.
I have two ajax calls so first ajax sends the data to the server and server checks and return the value and I want the returned values to the another ajax call but it seems like I am passing nothing in second ajax call.
First Ajax Call
function first(){
$.ajax({
url:window.location + '/first',
type: 'post',
data : $('form#first_form').serialize() //it will be like "name=Brad",
success: function(response){
consol.log(response.name); // I checked, and it returns "Brad"
second_ajax(response.name); //pass the returned value "Brad"
},error: function(){
}
});
}
Second Ajax call
function second(response_name){
$.ajax({
url:window.location + '/second',
type: 'get',
data : {username:response_name}//I am not sure how to write here, I want to send like 'username=Brad'
success: function(result){
},error: function(){
}
});
}
Server
app.get('/second', (req, res) => {
//get the username from the second ajax call
var user_name = req.body.username;} //I am getting nothing here...