Answer the question
In order to leave comments, you need to log in
Displaying json file, adding new lines to existing json file?
This is how I display it now. Result -> [object Object],[object Object],[object Object]
$(document).ready(function(){
$('#click').click(function(){
$.getJSON('myJson.json', {}, function(json){
$('#see').append('To: ' + json + '<br/>');
});
})
});
Так я отправляю данные. Нужно еще что бы при каждом клике добавлялась новая строка с данными.
var arr = [
{"name": "Вася", "age": 20},
{"name": "Петя", "age": 22},
{"name": "Таня", "age": 18}
];
$.ajax({
url: 'stat.php',
type: 'POST',
data: {myJson: JSON.stringify(arr), fileName: 'myJson.json'}
});
Это php
<?php
file_put_contents($_POST['fileName'], $_POST['myJson']);
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question