The array sent by ajax gives me failures

1

Hello good, I have a problem, I pass an array by ajax with this function to a controller in laravel and its values I want to store them in a database, the problem that I have esque in when I execute the database query the system cascates and only removes the first value from the vector if there is luck because the second time I press the button or that, however if it is not the query to the database I print it with echo and it is great, but this way I can save anything, could you help me ?.

    
asked by beaag58 31.01.2018 в 20:22
source

2 answers

0

Delete this line:

var frase = JSON.stringify(album);

Replace this line:

$.post(url, {data : frase}, function(msg) {

Because of this:

$.post(url, {data : album}, function(msg) { 

So from your controller you could already use

$_POST['data'];

as you require it.

    
answered by 02.02.2018 в 01:39
0

Try changing:

var frase = JSON.stringify(album);

By

var frase = JSON.parse(album);

This should return the entire array

    
answered by 02.02.2018 в 04:45