The add row request that should be made by datatables doesn't seem to send a request to the .php page. when i click Confirm on the AddNewRow form, it only adds a row to the datatable on the webpage, and doesnt alert me any output from the php page 'AddData.php' like Delete and Edit, the only code in it is an echo 'test', to see if it works.
I am using the Editable plugin for Datatables.
The form that is required in the HTML for the makeEditable AddNewRow开发者_JAVA技巧 plugin to work, works fine, the form displays with correct buttons and fields.
How can i test if its sending the AJAX request?, what functions or properties can i use to check the data being sent and change what data must be sent?
Here is the code to create my datatables:
$('#tmTabs').tabs( {
"show": function(event, ui) {
//make datatable columns resize to adjust to changing tabs
}
} );
$('.dataTable').each(function(){
//get ID of current table;
tblID = $(this).attr("id");
var pattern = "[0-9]+";
$tblIDNum = tblID.match(pattern);
//transform this table into a data table
$(this).dataTable({
"bProcessing":true,
"sScrollY": "600px",
"sScrollX": "100%",
"bScrollCollapse": true,
"bPaginate": false,
"bJQueryUI": true
})
.makeEditable({
//ajax requests for server-side processing
sUpdateURL: "UpdateData.php",
sAddURL: 'AddData.php',
sDeleteURL: "DeleteData.php",
sReadOnlyCellClass: "read_only",
//Button Customization
oAddNewRowButtonOptions: {
label: "Add...",
icons: { primary: 'ui-icon-plus' }
},
oDeleteRowButtonOptions: {
label: "Remove",
icons: { primary: 'ui-icon-trash' }
},
oAddNewRowOkButtonOptions: {
label: "Confirm",
icons: { primary: 'ui-icon-check' },
name: "action",
value: "add-new"
},
oAddNewRowCancelButtonOptions: {
label: "Close",
class: "back-class",
name: "action",
value: "cancel-add",
icons: { primary: 'ui-icon-close' }
},
oAddNewRowFormOptions: {
title: 'Add New Row',
show: "blind",
hide: "explode"
},
//Link button ids
sAddDeleteToolbarSelector: ".dataTables_length",
sAddNewRowFormId: "formAddNewRow"+$tblIDNum,
sAddNewRowButtonId: "btnAddNewRow"+$tblIDNum,
sAddNewRowOkButtonId: "btnAddNewRowOk"+$tblIDNum,
sAddNewRowCancelButtonId: "btnAddNewRowCancel"+$tblIDNum,
sDeleteRowButtonId: "btnDeleteRow"+$tblIDNum
});
enter code here
});
Use firebug net panel to see is the Ajax call finished.
If the row is added without any warning to the table then it seems that your php page is called and that it has returned something that is accepted by the plugin as an valid id of the new row.
Note that if your page returns any response, this response will be considered as an id of the new row. If you can find id attribute of the new row you will see that it has value that is returned from he server.
By your description I believe that your server page is called, that insert on the server side failed but plugin thinks that everything is fine, and row is added.
The only way to return error code from the server is to force Ajax error by setting the response status code to some error code e.g. 404 and plugin will then show response body in popup and cancel editing. See more details about the error handling on the http://code.google.com/p/jquery-datatables-editable/wiki/AddingNewRecords#Handling_server_errors
精彩评论