Category: json

How can I get my datatable via ajax request?

I try to load my datatable via Ajax: base.html.twig: <button class=”button”>load table</button> <div class=”result”></div> $(‘.button’).on( ‘click’, function () { $.ajax({ method:’POST’, data: { “id”: id, }, url:'{{ path(‘table’) }}’, success : function (data) { $(“.result”).html(data.output); } }); }); Controller: /**…

Symfony / php : avoid query to give nested json objects from one to many relation

I have entities; Command, User, GiftCheck, and GiftCheckType : GiftCheck <?php namespace AppEntity; use DoctrineORMMapping as ORM; /** * @ORMEntity(repositoryClass=”AppRepositoryGiftCheckRepository”) */ class GiftCheck { /** * @ORMId() * @ORMColumn(type=”integer”, length=255) *@ORMGeneratedValue(strategy=”AUTO”) */ private $id; /** * @ORMColumn(type=”string”, length=255, columnDefinition=”ENUM(‘Cadeau’, ‘Anniversaire’,…

Why I get a json response from symfony controller like this /[{ "id" : 1 ….}], its starts with "/"? [closed]

When I make a variable dump in the controller i get a clean json without “/” at the beginning ? I dont Know Why? someone could help me on this. My frontend client wont parse this JSON response with “/”…

Symfony serializer cannot deserialize into DateTime

I‘m trying to deserialize a json with the Symfony Serializer into a DTO, but I got always the exception Symfony/Component/Serializer/Exception/MissingConstructorArgumentsException with message ‘Cannot create an instance of DateTime from serialized data because its constructor requires parameter “time” to be present.’….

MYSQL – How to search in JSON array?

On my Symfony 5 app, i’ve a database with a candidate table that contains a json field. candidate 1 : [{“end”: “30/04/2020”, “start”: “01/03/2020”},{“end”: “31/07/2020”, “start”: “01/07/2020”}] candidate 2 : [{“end”: “31/03/2020”, “start”: “01/03/2020”},{“end”: “31/07/2020”, “start”: “01/07/2020”}] Is it possible…

How can I limit my database request according to the pagination of the datatable?

I am loading data from my database, which is a very high amount of data. To get a real fast performace, I limit the data (with my parts function) Controller.php $table = $this->em->getRepository($EntityName)->parts(10); $table_json = $serializer->serialize($table, ‘json’); $table_array = json_decode($table_json);…