i just want to pass the selected id of the option via ajax request to django 2.1 but it always returns me some errors . i am new to django and web development so please help to solve this issue js code
document.addEventListener('DOMContentLoaded',()=>{
document.querySelector('#mainoption').onchange=()=>{
const id=document.querySelector('#mainoption').value;
const request=new XMLHttpRequest;
request.open('GET','submain');
request.send(id);
alert("selected "+id);
}
});
django code
def submain(request):
subid = request.GET.get('id')
print(subid)
# return render()
Aucun commentaire:
Enregistrer un commentaire