Ajax call won't happen?
Ajax call won't happen?
Hi!
So I'm planning to use the standalone editor for one of my pages... Unfortunately the ajax call to the php-page won't happen. I have no idea why. I started with a very simple case for testing, and I have checked the filepaths a zillion times. I've even intentionally put errors in the php page to force an error, but it seems the call from the editor just doesn't happen...
Any idea why? I have also tried to put the editor code just below document.ready instead. When I check the XHR Parameters and responses, there are none. The latest parameters are for the first function checkAccess()...
Here's the very simple code, the alert does show, so I get~~~~ inside the function.
var editor;
$(document).ready(function() {
function checkAccess(){
$.ajax({
type: 'POST',
url: "../_includes/process_drillborra.php",
dataType: 'json',
data: {action: 'checkaccess'},
success: function(response) {
if(response["valid"]){
if(response["access"] === "none"){
//...........................
}
else if(response["access"] === "rs"){
getShift();//this is the function called and where the editor is supposed to run..
}
else if(response["access"] === "r"){
//....................................
}
else{
//:::::::::::::::::::::::::::::::::::
}
}
else{
$("#msg-div").addClass("danger").html(response["msg"]).show("slow").delay(3000).hide("slow");
return;
}
},
error: function(){
}
});
};
};
//Below is the function with the editor inside
function getShift(){
editor = new $.fn.dataTable.Editor( {
ajax: "../_includes/process_getshift.php",
fields: [ {
label: "Server IP address:",
name: "server-ip"
}
]
} );
$('#shift-panel').collapse('show');
$(window).scrollTop(0);
};
});
This question has an accepted answers - jump to answer
Answers
Just thinking: Does the standalone work so that the initial data must already be fetched and displayed inside the html elements? So that the ajax call is only executed when editing this data?
Can't find any example of php-code used for standalone mode. I thought I could use the Editor::inst on the server side just like when I use normal tables, but maybe it's not the case? How can the serverside know what fields in the database to update, especially in the case where I have several table joins with maybe the same column names but different tables?
So I've fetched the initial data from another php-page and inserted it into the html. It shows and my editor bubble opens with the correct value...
However, I need to pass the table id to the server page when editing, and I can't wrap my head around how it's done... I've seen edit() can pass a value which is automatically sent as id to the server page. But where do I set it?? here's my javascript:
Another update:
Managed to get it working. Found out I can set the surrounding
<
div> having the data-editor-id which I set to the right id.
So now it updates the database...
However, it does not update the page I'm on, even though the manual clearly says it should automatically do that?
Edit: Ok, got that solved as well. The data-editor-id must be row_4, not rowid_4...
Nice inner monologue :-). Good to hear you got it working in the end!
Allan