Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

259
Views
What is the syntax to pass a query in the ajax url using Django

I'm opening a modal with ajax, but I'm having a problem because I need to access a url on my site that needs a query

<script>
document.getElementById('myBtn2').onclick = function(){
    $.ajax({
       url:"{% url 'add_data' %}?filter=crew",
       type:'GET',
       success: function(data){
           $('#modal-content2').html(data);
       }
    });
}
</script>

I can't access url with the query, just the url alone. for example:

url:"{% url 'index' %}" 

But if I put a query in the url it still doesn't work. I think the syntax is wrong and I can't figure out what it looks like.

url:"{% url 'add_dados' %}?filter=crew" --> doesn't work

Any suggests?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You pass the querystring as dictionary when making an AJAX request:

document.getElementById('myBtn2').onclick = function(){
    $.ajax({
       url:"{% url 'add_data' %}",
       type:'GET',
       data: {
           filter: "crew"
       },
       success: function(data){
           $('#modal-content2').html(data);
       }
    });
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!