make an ajax-call on'click' leads to never-ending re-load of table
make an ajax-call on'click' leads to never-ending re-load of table
I have a datatable all set and happy. I set a "on-click event" for the whole table with an alert
$('table tbody').on( 'click', 'td', function () {alert( '__plugName__' + ' ' + 'XSelectInvoice' + ' ' + table.cell( this, 6 ).data()) } );
still everything happy!
But: I actually want to call a defined function. The function called e.g. per
<a href="#" style="color: #365784; text-decoration: none;" title="Freigeben" onclick=" ajax_call(...)>
does workl
But I need it in the table, as I am passing table-values to the function:
$('table tbody').on( 'click', 'td', ajax_call('__plugName__', 'XSelectInvoice', table.cell( this, 7 ).data(), table.cell( this, 6 ).data(), ) );
Now the table is loading and without pause (or any chance to click it) reloading without end time after time.
Any idea what causes this behaviour?
Thanks
Max
This question has an accepted answers - jump to answer
Answers
I would start by looking at what the
ajax_call()
function is doing. Can you post a link to your page or provide a test case showing the issue so we can help debug?https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
For me the interesting point seems to be, that this ajax_call is never called - there is no click event.
I have installed a test possibility:
freigabe.kontura at
User: test@max.at password: Max
In "Erledigte Freigabe" it works with the alert.
In "Erledigte Freigabe 2" the only differene is the other "on-click" event, here it does not work.
Thanks!
Max
And you asked for the ajax_call - here it is:
I don't see a link to your test case.
That looks like it might be your server script? I was suggesting that you look at the
ajax_call()
function in Javascript. But you are saying that its not called.I'm confused by your problem description. Please post a link to your test case with specific steps needed to cause the issue.
Kevin
Hi Kevin,
here the test case:
I have installed a test possibility:
http://freigabe.kontura.at/
User: test@max.at password: Max
Thanks
Max
This is an interesting page. Took awhile to understand how the page is working. Looks like you are fetching, via ajax, each page then using
eval(v)
to load the page contents.I'm not sure why the page is continuously being reloaded but it doesn't seem to be specific to Datatables. I'm not sure what is initially calling
ajax_call()
but that is the place to start troubleshooting.I placed a breakpoint on lines 51 and 66 in ajax.js to take a look. Maybe you can continue from here by setting those breakpoints. I did find some issues:
Then again at line 86:
In addition to not loading the .js files multiple time you need to load them in order. Looks like you are loading editor.js before datatables.js.
Erledigte Freigabe
you are getting this Javascript error:I wonder if that error is actually stopping this page from reloading continuously.
Its not identical because it doesn't generate the
editor is not defined
error. Once the page is loaded without something triggers it to call ajax_call() and reload the page. Again I suggest you start with debugging the code that initially calls ajax_call() to see what it is doing. I'm not sure what it is.Clean up the JS and CSS includes. Use the Download Builder to get the proper files. Clean up the Javascript errors and debug the function that call ajax_call(). Let us know what you find.
Kevin
It just clicked what the problem is. Copy your click event into a Javascript REPL and you will see the problem:
Take a look here:
http://live.datatables.net/sozucajo/1/edit
It is executing the function when the statement is loaded.
EDIT: Take a look at the browser's console for an error stating ajax_call() can't be found.
You need to use an anonymous function like this:
This way it won't execute until the cell is clicked.
Kevin
you ARE GREAT from my point of view!!!! Problem solved!
Thanks Max
Glad to help. It was an interesting problem to debug
Kevin