In Ajax call populating data dynamically in html page.
Requirement : After populating if we click on button it should invoke JavaScript function along with required to pass object. In JavaScript we need to access data using like value.id, value.title, value.description..... (Expected result) But i am unable to fetch data from function argument, i tried with stringify, parse methods but didn't.
Please tell me, how can i access in JavaScript function?
success : function(data) {
var listData = null;
$.each(data.documentsList,function(index, value) {
//some logic ----------(iam able to get value.id, value.title, value.description...)
listData += '<button value="Update" onclick="updateDocument(\''+ value + '\')">Update</button>'
//some logic ----------
});//each loop end
$('#list').html(listData);
},//success end
function updateDocument(document) {
console.log("updateDocument" + document); //[object object]
console.log(document.title); //undefined
}