Problem with inicialization Ajax
Problem with inicialization Ajax
Hi,
I have a problem with initialization ajax call from Database Editor plugin. I am using Spring MVC for backend and JSP pages for views. This is my initialization JS script and part of html code:
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.11/css/jquery.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/1.1.2/css/buttons.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/select/1.1.2/css/select.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="https://editor.datatables.net/extensions/Editor/css/editor.dataTables.min.css">
<script type="text/javascript" src="//code.jquery.com/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.11/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.1.2/js/dataTables.buttons.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/select/1.1.2/js/dataTables.select.min.js"></script>
<script type="text/javascript" src="https://editor.datatables.net/extensions/Editor/js/dataTables.editor.min.js"></script>
<script type="text/javascript" class="init">
var editor; // use a global for the submit and return data rendering in the examples
$(document).ready(function() {
editor = new $.fn.dataTable.Editor( {
ajax: 'flatTypesAjaxLoad',
table: '#example',
fields: [ {
label: 'Name:',
name: 'name'
}, {
label: 'Name_CZ',
name: 'nameCZ'
}
]
} );
// Activate an inline edit on click of a table cell
$('#example').on( 'click', 'tbody td:not(:first-child)', function (e) {
editor.inline( this );
} );
$('#example').DataTable( {
dom: 'Bfrtip',
ajax: 'flatTypesAjaxLoad',
columns: [
{
data: null,
defaultContent: '',
className: 'select-checkbox',
orderable: false
},
{ data: 'name' },
{ data: 'nameCZ' },
],
select: {
style: 'os',
selector: 'td:first-child'
},
buttons: [
{ extend: 'create', editor: editor },
{ extend: 'edit', editor: editor },
{ extend: 'remove', editor: editor }
]
} );
} );
</script>
.
.
<table id="example" class="display">
<thead>
<tr>
<th>Type</th>
<th>Type in CZ<th>
</tr>
</thead>
</table>
I've created a simple controller for testing whether initialization ajax call was made:
@RequestMapping(value = "estate/flatTypesAjaxLoad", method = RequestMethod.GET)
public @ResponseBody
String getflatTypesAjaxLoad() {
final String result = "something";
System.out.println("-------------------------------- test text -------------------------------------");
return result;
}
If I load (or refresh) the page, I supposed that the Database will made initialization request to configured URL and the application will print a testing text. But nothing happens. I do not suppose that the problem was in backend of the application, because other ajax calls are working properly.
Moreover, I tested app with firebug tool and the Database really doesn't sent any request.
Can you help me?
Thanks
This question has an accepted answers - jump to answer
Answers
Nobody has any idea?
What does
flatTypesAjaxLoad
return? You can use your browser's developer tools to check.If you could post a link to a test case, I can take a look and offer some help.
Allan
Hi,
flatTypesAjaxLoad return nothing, getflatTypesAjaxLoad() method will not start.
I used developer tool (firebug) and Datatables Editor plugin doesn't sent any request.
Unfortunately, project is only on my PC
Thanks
Kotrba
So when you inline edit something, no Ajax request is submitted to the server (checked by your browser's "Network" developer tools)? Are there any errors shown in your browser's console? I don't see anything in the above code that would explain why no Ajax result would be submitted I'm afraid.
Allan
The answer is yes, but I don't know what would happen when inline edit. Because I have not some table, because the init Ajax not submitted
I'm afraid I'm not understanding - sorry. Are you saying that the initial Ajax data fetch isn't working?
Can you put the page on a public server so I can take a look please?
Allan
Yes, initial data fetch not working. But maybe, I'm really idiot, I have only trial version for testing and trial was expired....
I've reset your trial should you wish to try it again. An updated version can be downloaded from the the download page when logged in with your account.
Only the dataTables.editor.js and dataTables.editor.min.js files need to be updated in your current install from the updated trial package.
The updated trial will run for an additional 15 days from this point.
Regards,
Allan
Hi Allan, I downloaded new version and tested it again. Now, some things are better.
Now, on my page is a skeleton of table with headers and defined buttons (New, Edit and Delete).
Now I can click on New button and fill the opened form and If I click on create button in form, the ajax request is send on defined url and recieve some data.This is good.
But initial ajax call still not working, I am really crazy from this :)
Simple question: In downloaded bundle from download page are several files. That are files from this bundle are neccessary for basic function of Editor?
Thanks
Kotrba
The updated trial will run for an additional 15 days from this point.
[URL="http://upx100.com/1460319037.html"][IMG]http://upx100.com/img/1460319037.jpg[/IMG][/URL]
Can you give me a link to the page showing the issue so I can see what the issue is please? When you say the initial Ajax call, do you mean the one DataTables is making to fetch the data? If so, in what way is it not working? Any error messages?
The HTML to include the required Javascript and CSS are shown at the bottom of the download page. You don't need to include the individual files yourself.
I would suggest using:
as the base line for using Editor.
Regards,
Allan
Hi Allan, I am resolved it. The problem was in column configurations. In initialization script for editor I am defined only two columns (name and nameCZ), but in dataTable script I am defined three columns (name, nameCZ and checkbox column for selecting rows). After correction, everything is all right. Thank you for your help