I have 2 input's:
<td><input id='someName_1' type='textbox' value='1' /><td>
<td><input id='someID_1' class="button1" type='button' value='Submit' /></td>
I have below ajax code:
$("body").on('click', '.button1', function () {
var params = { id: this.id, value: (?) };
$.ajax({
type: 'POST',
url: '@Url.Action(SomeUrl- pointless)',
dataType: 'json',
cache: false,
contentType: 'application/json; charset=utf8',
data: JSON.stringify(params),
success: function (data, status) {
doingsomething
},
error: function (er, info) {
},
complete: function (xhr, status) {
},
});
});
Question is: how i can get value in variable 'params', field 'value' from textbox with someID_1, if all my id's are created dynamically via response from server? Input's are too created dinamically.
There is code which generated my input's:
var s = [];
$.each(data.items, function (i, item) {
var t = "<td><input id='someName_" + item.id + "' type='textbox' value='1' /></td>" +
"<td><input id='someID_" + item.id + "' class='button1' type='button' value='Submit' /></td></tr>";
s.push(t);
});
$('body').html(s.join(""));