while ($row = mysqli_fetch_assoc($result)) {
json_encode($row);
}
mysqli_free_result($result);
}
mysqli_close($db);
if(isset($_POST['data'])) {
echo $row;
}
$('.js-choice').on('click', function() {
var data = $('.js-choice').val();
$.post(
'form.php',
{data: data},
function (data) {
console.log(JSON.parse(data));
$('.js-id').text(data.id);
$('.js-name').text(data.name);
$('.js-summary').text(data.summary);
$('.js-description').text(data.description);
},
'text',
);
});
if(isset($_POST['data'])) {
json_encode($row);
}
$arr = array(
array(
"slide_1" => "Winterfell.jpg",
"slide_2" => "The_Eyrie.jp",
"slide_3" => "Riverrun (2).jpg",
"slide_4" => "Pyke.jpg",
"slide_5" => "Winterfell.jpg",
"slide_6" => "The_Eyrie.jp",
"slide_7" => "Riverrun (2).jpg",
"slide_8" => "Pyke.jpg",
),
array(
"slide_1" => "Winterfell.jpg",
"slide_2" => "The_Eyrie.jp",
"slide_3" => "Riverrun (2).jpg",
"slide_4" => "Pyke.jpg",
"slide_5" => "Winterfell.jpg",
"slide_6" => "The_Eyrie.jp",
"slide_7" => "Riverrun (2).jpg",
"slide_8" => "Pyke.jpg",
),
array(
"slide_1" => "Winterfell.jpg",
"slide_2" => "The_Eyrie.jp",
"slide_3" => "Riverrun (2).jpg",
"slide_4" => "Pyke.jpg",
"slide_5" => "Winterfell.jpg",
"slide_6" => "The_Eyrie.jp",
"slide_7" => "Riverrun (2).jpg",
"slide_8" => "Pyke.jpg",
),
array(
"slide_1" => "Winterfell.jpg",
"slide_2" => "The_Eyrie.jp",
"slide_3" => "Riverrun (2).jpg",
"slide_4" => "Pyke.jpg",
"slide_5" => "Winterfell.jpg",
"slide_6" => "The_Eyrie.jp",
"slide_7" => "Riverrun (2).jpg",
"slide_8" => "Pyke.jpg",
),
);
[
{"slide_1":"Winterfell.jpg",
"slide_2":"The_Eyrie.jp",
"slide_3":"Riverrun (2).jpg",
"slide_4":"Pyke.jpg",
},
{"slide_1":"Winterfell.jpg",
"slide_2":"The_Eyrie.jp",
"slide_3":"Riverrun (2).jpg",
"slide_4":"Pyke.jpg",
},
{"slide_1":"Winterfell.jpg",
"slide_2":"The_Eyrie.jp",
"slide_3":"Riverrun (2).jpg",
"slide_4":"Pyke.jpg",
},
{"slide_1":"Winterfell.jpg",
"slide_2":"The_Eyrie.jp",
"slide_3":"Riverrun (2).jpg",
"slide_4":"Pyke.jpg",
},
{"slide_1":"Winterfell.jpg",
"slide_2":"The_Eyrie.jp",
"slide_3":"Riverrun (2).jpg",
"slide_4":"Pyke.jpg",
},
{"slide_1":"Winterfell.jpg",
"slide_2":"The_Eyrie.jp",
"slide_3":"Riverrun (2).jpg",
"slide_4":"Pyke.jpg",
},
{"slide_1":"Winterfell.jpg",
"slide_2":"The_Eyrie.jp",
"slide_3":"Riverrun (2).jpg",
"slide_4":"Pyke.jpg",
},
{"slide_1":"Winterfell.jpg",
"slide_2":"The_Eyrie.jp",
"slide_3":"Riverrun (2).jpg",
"slide_4":"Pyke.jpg",
},
]
$arr = array(
$img_1 = array {
"slide_1":"Winterfell.jpg",
"slide_2":"The_Eyrie.jp",
"slide_3":"Riverrun (2).jpg",
"slide_4":"Pyke.jpg",
},
);
$dsa = $_POST['data'];
var_dump(json_decode($dsa));
var_dump(json_decode($dsa, true));
Попробуйте сразу инициализировать data этим своим массимов, а не вытаскивать его из блока html.
$(function() {
var data = ($("#json").html());
console.log(data);
$.ajax({
type:'POST',
url: '../index.php',
data: {data: data},
success: function(){
alert('Успех!');
}
});
});
var data = $("#json").html();
console.log(data);