Код: Выделить всё
const dateInput= document.getElementById('dateInput');
const selectedDate = new Date(dateInput.value);
$.ajax({
type: 'get',
url: '{{route("demo.function")}}',
data: {
'date' : selectedDate.toISOString().split('T')[0]
},
success: function(data) {
var info = data.info;
console.log("Information: " + info);
},
error: function(error) {
console.log(error,'There is some error here!');
}
});
После вызова функции в контроллере следующим образом:
Код: Выделить всё
public function demoFunction(Request $request){
$date = $request->input('date');
$info = getData($date); // Api call function
return response()->json(['message' => 'Data processed successfully', 'info'=> $info]);
}
Код: Выделить всё
public function getData($date){
for($i=0; $irequest('POST', 'http://xx.xx.xx.xx/my-ws/dynamic-data.html', [
'headers' => [
'Content-Type' => 'text/xml; charset=utf-8',
],
'body' => $Payload,
]);
} catch (\Exception $e) {
return response()->json(['error' => 'Request is not successfull'], 500);
}
$info[] = [
'info' => $response->getBody();
];
}
return $info;
}
Подробнее здесь: https://stackoverflow.com/questions/790 ... atus-of-50