an AJAX returned function?
What I am trying to do with $id is get it returned from the clicked table row event function, grab the id and pass it to the delete.php page through AJAX GET in the url. I don't know if I can have the click event function inside the AJAX function like this?
$.ajax( {
var $id= $('.x').on( 'click', 'tr', function (e) {
var id= $( this ).closest( 'tr' ).get(tr[id]);
$(this).closest('tr').remove();
return id;}
type:"GET",
data: "",
dataType: "json",
url: 'ajax/delete.php?id=+id',
field: $(this).attr("id"),
statusCode: {
404: function() {
$('#response').html('Could not contact server.');
},
500: function() {
$('#response').html('A server-side error has occurred.');
}
},
success: function(data) {
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);}
} );
} );