【发布时间】:2018-05-31 17:30:37
【问题描述】:
我想知道如何让我的 ajax 请求在 crontab 中运行? 我在这里有一个从 api 获取数据的 ajax 请求,对于我正在执行 ajax 发布请求以更新数据库中的一行的每个数据。
如何在 Curl 中执行此操作?
这是我的脚本,
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);
}
})
}
}
});
}
我还传递了请求标头和 xhr 字段,
我希望有人能帮我解决这个问题,如果在 ajax 上不可能,你能帮我在 Curl 或任何可能的解决方案上完成这个, 谢谢!
【问题讨论】:
-
检查我的答案,它就像你的问题的原型