I have a problem, I wrote a function for printing message data from a JSON file, but I do not know how to remove message data with specific id and reply on message to sender? Do I use only javascript or I have to use PHP? Can somebody help me?
My data.json file:
{
"data":[
{
"id":"2146",
"from":{
"id":"234",
"name":"Alan Ford"
},
"to":{
"id":"4949",
"name":"Eric Owens"
},
"type":"1",
"replyto":"0",
"date_sent":"1344359836",
"date_read":"0",
"subject":"test",
"message":"test inbox",
"message_formatted":"test inbox",
"date_sent_formatted":{
"id":1196,
"timestamp":1344297600,
"month":8,
"day":7,
"year":2012,
"week":32,
"dayid":3,
"weekday":"Tue",
"mname":"Aug",
"formatted":"Aug 7, 2012"
},
"date_read_formatted":[
]
},
{
"id":"2048",
"from":{
"id":"234",
"name":"Alan Ford"
},
"to":{
"id":"8110",
"name":"Event"
},
"type":"1",
"replyto":"0",
"date_sent":"1343248577",
"date_read":"0",
"subject":"afd",
"message":"asdfads",
"message_formatted":"asdfads",
"date_sent_formatted":{
"id":1184,
"timestamp":1343260800,
"month":7,
"day":26,
"year":2012,
"week":30,
"dayid":5,
"weekday":"Thu",
"mname":"Jul",
"formatted":"Jul 26, 2012"
},
"date_read_formatted":[
]
}
]
}
My jquery file:
$(document).ready(function(){
$.getJSON('public/js/data.json', function(json){
var msg = json.data
for ( i = 0; i < msg.length; i++ ) {
var content = '<li>';
content += '<span class="left">' + msg[i].from.name +'</span>';
content += '<span class="right">'+ msg[i].date_sent_formatted.formatted +'</span>';
content += '<p>' + msg[i].subject + '</p>';
content += '<p>' + msg[i].message + '</p>';
content += '<button>Replay</button>';
content += '<button>Delete</button>';
content += '</li>';
$('.content').append(content);
}
});
});
function delete_message(id){
}
function reply_message(id, sender){
}