how to dynamically change the url ajax?
how to dynamically change the url ajax?
Law004
Posts: 10Questions: 1Answers: 0
I want to call a hyperlink in a modal window, the problem is that I can not recall the date variable + data + into the " #example00" "url" , Please Help !!
<script type="text/javascript">
$(document).ready(function () {
$('#example').DataTable( {
"ajax": {
"url": "http://192.168.6.251:3000/clienti",
"dataSrc": ""
},
prerender:true,
"language": {
"url": "https://cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Italian.json"
},
dom: 'Bfrtip',
buttons: [
'excelHtml5',
'csvHtml5',
'pdfHtml5'
],
"columns": [
{ "data": "COD_CF",
"render": function(data, type, full, meta) {
return '<a id="'+ data +'" href="'+ data +'" data-toggle="modal" data-target="#myModal" >' + data + '</a>';
}
},
{ "data": "Denominazione"},
{ "data": "Tel" },
{ "data": "Email" },
{ "data": "Indirizzo" },
{ "data": "Comune" },
{ "data": "PROV" },
{ "data": "CAP" },
{ "data": "P_IVa" }
]
});
$('#example00').DataTable( {
"ajax": {
"url": "http://192.168.6.251:3000/listaddtIN?codiceCliente= I want THE VARIABLE + date + HERE ",
"dataSrc": ""
},
prerender:true,
"language": {
"url": "https://cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Italian.json"
},
dom: 'Bfrtip',
buttons: [
'excelHtml5',
'csvHtml5',
'pdfHtml5'
],
"columns": [
{ "data": "DOC_ID" },
{ "data": "ANNO_DOC" },
{ "data": "NUM_DOC" }
// { "data": new Date("DATA_DOC").getDate()}
]
});
});
</script>
This discussion has been closed.
Answers
ajax.url().load()
hi thanks for the reply I have already tested this feature and does not work :-(
I tried this feature but it does not work ...
I get a message that says INVALID JSON response !!!
Did you inspect that rendered <a> to be sure the code is clean? Is the onclick firing?
I also checked the " "
Oh wait, so in the two different JSON responses, is the structure different as well? I notice the
columns
is different between the two tables, so if its different, thats an issue. Youd need to destroy and recreate the entire tableOh, you want data to go with the ajax request? You can use
ajax.data
sure tables are different, they also have two different id they are example and example00
Oh then nevermind, I thought you were reloading hte same table.
if you need to pass data with the ajax req, just use
ajax.data
I'm trying not work
Im honestly not sure what you just tried to ask..
I'm trying not work
Why doesnt it work? what error do you get? any logs in the console?
Need details man.. make it easy for us to help you..
don't call the json, when I click on the link to show the new table into the modal window #MyModal, it loading ... , and can not find the json.....
I tried the first example of the links that I you posted, and unfortunately does not work