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

142
Views
Making an Ajax call with both url and query parameters

I have a simple endpoint in flask like the below.

@ns.route ('/cars/<string:make>/<string:model>')

class CarClass (Resource):
    def get (self, make):
        year=request.args.get ('year', type=int)
        website=request.args.get ('website', type=path)
        # do something

Important points to consider are as follows

  1. URL Parameters introduced to illustrate that these are mandatory parameters and the order matters
  2. Query Parameters introduced to illustrate that there are optional parameters (with no relevant ordering)
  3. Website Parameter introduced to illustrate complications with forward slashes and the need to encode paths

When making the API call I think I can pass the query parameters through the data portion, but I am forced to manual create the URL and make an ajax call, like so

url = `https://example.com/cars/${make}/${model}`

try
{
    data = await $.ajax({
    type: 'GET',
    url: url,
    data: JSON.stringify({
        year: year,
        website: website
    }),
    datatype: 'json',
    contentType: 'application/json; charset=utf-8'
    });
}

Is there a builtin Ajax way of passing URL parameters or must I resort to such string manipulation of the URL?

Background: I find the majority of answers to my question simply tell the coder to put the parameters into an object and pass it to data, but when I do this I get a 404 error because the API is looking for /cars/<make>/<model> not /cars

  • How to pass parameter in AJAX URL?
  • How to pass parameters in GET requests with jQuery
about 4 years ago · Juan Pablo Isaza
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!