Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

144
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda