I'm trying to utilize JSON for updating database records without triggering a postback, but I'm struggling with the implementation. This is my first time attempting this, so any guidance in the right direction would be greatly appreciated.
(Note: The irrelevant explanation – I have a list of sortable items with editable text using a jQuery plugin. When users click submit, I want their records to be updated. The functionality will resemble something like this.)
This specific JavaScript function creates an array of objects. However, I'm unsure about the next steps after generating the array. It gets invoked by the button's onClick event.
function SaveLinks() {
var list = document.getElementById('sortable1');
var links = [];
for (var i = 0; i < list.childNodes.length; i++) {
var link = {};
link.id = list.childNodes[i].childNodes[0].innerText;
link.title = list.childNodes[i].childNodes[1].innerText;
link.description = list.childNodes[i].childNodes[2].innerText;
link.url = list.childNodes[i].childNodes[3].innerText;
links.push(link);
}
//This is the part where I need help deciding what to do with my array.
}
I aim to trigger an update method through this process to save the data into the database. Below is the code-behind function that the JavaScript will call.
public void SaveList(object o )
{
//Need to cast and process the information
}
All assistance is welcome!