Using the following script:
$("#some_button").click(function() {
var changed = [];
$( 'input[id$="_0"]' ).each(function() {
var new_id = this.id.replace( '_0', '_1' );
if ( $(this).val() !== $( 'input#' + new_id ).val() ) {
changed.push(new_id);
// send back id, new value from _0, and old value from _1
}
});
console.log(changed);
});
I need to send back the id, the old value from _1 and the new value from _0 back to the server. What is the best way to format this data so I can easily extract the data from the server side so I can easily email someone for example to let them know which textboxes have changed, what the old values were, and what the new values are
At the serverside level, I am using .NET-3.5 (VB).
I know how to send the data bacl. and how to email the data, I just wanted to know how to best format the data at clientside before sending it back.
I could have upto 50 sets of id, old, and new values to send back. Sorry for not making that clear earlier.
Example:
How can I modify the script above to generate this?
[
{
"id": "name_0",
"new": "text",
"old": "text"
},
{
"id": "age_0",
"new": "text",
"old": "text"
},
{
"id": "dept_0",
"new": "text",
"old": "text"
}
]
On the client side:
instead
Later:
On the server side:
Old answer, obsolte because of many items transported.
If your data is short enough, just encode it in the url.