I have a problem with Ajax Request URL syntax in the Javascript File. When the code is in the html file everything is correct.
html file
$.ajax({
url: '{% url "ajax_load_listanumerowproduktu" %}', // This syntax '{% %}' is a problem
data: {
'numerproduktu': numerproduktuId
},
success: function (response) { // jeśli sukces to pobieram to co wysłano przez funkcję load_polepomocnicze
$("#id_iloscnamagazynie").val(response.wartoscnamagazynie);
console.log('response'); // drukuję do konsoli PRZEGLĄDARKI
console.log(response);
},
error: function (){
console.log('brak na magzynie takiego numeru');
{#alert('brak na magzynie takiego numeru')#}
$("#id_iloscnamagazynie").val(0);
},
});
urls.py
# AJAX
path('ajax/load_listanumerowproduktu/', views.load_listanumerowproduktu, name='ajax_load_listanumerowproduktu'),
I know that each file type has it own code interpreter. And for TEMPLATE LANGUAGE I set Django thats why I use {# #} to comment code.
My question is how can I use other syntax for URL in Ajax Request save in Javascript file?
I need figure out it to make my project clear and do not centralize information in long file… I want seperate files…