mercredi 23 janvier 2019

how to solve this error with django and ajax?

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()

the selected part is code for getting data from ajax req. below shows the error

javascript

frontend




Aucun commentaire:

Enregistrer un commentaire