Tuesday, 27 August 2013

button will not fire jquery

button will not fire jquery

javascript- the .remove button will not fire the javascript. I am not sure
whats wrong with this jquery. The add button click function works just
fine.
function formfill(dblist) {
var tableheader = "<thead><tr><th>Database Nick</th><th>Database IP</th>
<th></th></tr></thead>";
$('#table2').empty();
$('#table2').append(tableheader);
$.each(dblist, function (index, item) {
$('#table2').append('<tr><td>'
+ item['DBNick']
+ '</td><td>'
+ item['DBIP']
+ '</td><td><input class="remove" value="remove"
type="button"></input></td> </tr>');
});
}
$('#userlist').on('change', function gettable() {
var selected = $('#userlist').val();
$.ajax({
url: '/php/user/userdbtable.php',
type: 'POST',
data: { user: selected },
success: function (data) {
formfill(data)
},
error: function (xhr, status, err) { console.log(xhr, status, err); }
});
});
$("#add").click(function () {
var userselected = $('#userlist').val();
var dbselected = $('#dblist').val();
$.ajax({
url: '/php/user/userdblistadd.php',
type: 'POST',
data: { user: userselected, db: dbselected },
success: function (data) {
formfill(data)
},
error: function (xhr, status, err) { console.log(xhr, status, err); }
});
});
$(".add").click(function () {
var userselected = $('#userlist').val();
var dbselected = $(this).closest('tr').children('td.one').text().val();
console.log(dbselected);
$.ajax({
url: '/php/user/userdblistremove.php',
type: 'POST',
data: { user: userselected, db: dbselected },
success: function (data) {
formfill(data)
},
error: function (xhr, status, err) { console.log(xhr, status, err); }
});
});
javascript- the .remove button will not fire the javascript. I am not sure
whats wrong with this jquery. The add button click function works just
fine.

No comments:

Post a Comment