I want to know how do I make my ajax request run in crontab? I have here an ajax request that gets data from an api, for each data I'm executing ajax post request to update a row in my database.
How do I do this in Curl?
here is my script,
function getDataFs()
{
var _token = $("input[name='_token']").val();
$.ajax({
url: 'https://url/api/employees',
type: 'GET',
dataType: 'json',
xhrFields: {
withCredentials: true
},
success: function(response){
console.log(response);
for(i=0; i < response.length; i++)
{
$.ajax({
url: '/api/update_employees_list',
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
type: 'POST',
dataType: 'json',
data: { 'employee_data': response[i], '_token': _token },
success: function(response){
console.log(response);
}
})
}
}
});
}
I'm also passing request headers and xhr fields,
I hope someone can help me with this, If not possible on ajax , can you help me accomplish this on Curl or any possible solution for this, Thank You!