I would like to display data using jquery and ajax in a table in my twig file.
The ajax request sent a post request to the controller, the controller tried to insert severl row from a csv file in the database, but some error data cannot be inserted and I would like to display these data to the client using ajax and jQuery.
The data should be displayed in a table in my twig file. Until now, I can return the data, but I can't display the data in a table.
This is my ajax code:
jQuery('#formulaire').ajaxForm({
beforeSubmit: function (arr, $form, options) {
var ids = [];
var values=[];
$('li.ui-selected').each(function(){
ids.push(this.id);
values.push(this.value);
});
arr.push({name:'hide', value:(ids)})
arr.push({name:'valueschamps', value:(values)});
},
success: function (result, request) {
var parsedData =JSON.parse(result);
jQuery('#data').append(parsedData.data);
//jQuery('#data').html(parsedData.data);
},
error: function () {
jQuery('#main-content').html("errors");
}
});
In my controller I have:
$response = new JsonResponse();
$dataToReturn = array('data' => $dataerror);
$response->setData($dataToReturn);
return $response;
The result returned is as follows:
I want to display the data returned by the controller in a table inside the twig file. I tested several solutions, but does not work.
Any Help please
