Skip to content
Advertisement

Laravel ajax passing data to php

I have a special problem.

I am making an Ajax request to get data from the db without updating. The response I get should be outputted in a advanced way like this:

JavaScript

Right now I get the correct response from the Ajax request.

JavaScript

But how do I output it like that, with the include also and it should appear many times (its a calendar system that gets tasks from each days)

The Ajax request POST 2 dates (from and to) till a laravel controller which returns the tasks that have the date in between.

JavaScript

Advertisement

Answer

What you can do in your “/task/get” endpoint method is to return a view that returns a rendered html. then set the rendered response with javascript in a div element instead of that foreach loop.

So place the foreach code part in an include/partial like partial/tasks.blade.php and in your endpoint method:

JavaScript

Keep in mind to clear/empty the div before you make another request to the task/get endpoint.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement