The following works perfectly until I try to replace the hard coded “service_id” with the passed string variable id_name.
Is there a way to pass a variable into this part of the options?, If so, how be it?
Working version:
function deleteRecord(id)
{
$.ajax({
'url': url_root+'admin/index',
'type': 'POST',
'data': {"service_id" : id,
'ajax_name': 'services_list_table'
},
'dataType': 'json',
'success': function(data)
{
$("#ajax_services_table").html(data.html);
}
});
}
Not working version (passing in the “service_id” as a variable)
function deleteRecord(id,id_name)
{
$.ajax({
'url': url_root+'admin/index',
'type': 'POST',
'data': {id_name : id,
'ajax_name': 'services_list_table'
},
'dataType': 'json',
'success': function(data)
{
$("#ajax_services_table").html(data.html);
}
});
}
You would need to do…
Then pass
datatodataof your$.ajax().