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

193
Vistas
Extract states from URL to Json arrays (Select2 based webpage)

Sorry I am posting duplicate post. I am beginner in JavaScript (and web programing) and I didn't leant it. I just modify the demo codes without knowing details of code.

I want to collect database of cities from a post website. That website uses select2 jQuery. I know the API URL to all sub-sub category but this API seems expire after short time. Because of this I can't use this API in my project. The API URL is as follows:

https://www. .com/api/ /query?catalog=city&state=XX or

https://www. .com/api/ /query?state=XX&catalog=city&village=YYYY

where XX is a two digits number ranging from 01 to 40 for example and blank spaces are time-dependence random string. (I know this just by try and error.) and YYYYY is a five digits number ranging from 11111 to 99999 for example. In summary it has 5 dropdown list: State, Township, Region, City, Village.

One example of the above URLs is as follow (in chrome and without any extension .Js or .Json or any.):

[{"id":12345,"text":"city name1"},{"id":12346,"text":"city name2"}]

in HTML it is

<html>
<head>
</head>
<body>
<pre style="word-wrap: break-word; white-space: pre-wrap;">
[{"id":12345,"text":"city name1"},{"id":12346,"text":"city name2"}]
</pre>
</body>
</html>

and after a short time about 1 hour it return

<html>
<head>
</head>
<body>
<pre style="word-wrap: break-word; white-space: pre-wrap;">
{"errorCode":"invalid token"}
</pre>
</body>
</html>

I want to write a loop to collect all these data into a single Json file but stackoverflow posts confused me. Do you have any solution for this?

Is there a simple way just with the knowledge of select2? (knowing that where it store database or etc.)

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