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

248
Views
Convertir jquery ajax para buscar

¿Alguien sabe jquery y puede ayudarme a convertir este ajax a js fetch? Desafortunadamente, no conozco jquery y necesito convertir esto en js fetch.

 function ajaxLogoutDetailsApi() { $.ajax({ type: "GET", url: "OIDCGetLogoutDetails", async: false, cache: false, data: "json", success: function (data, status, xhr) { data = data.replace('\/\*', ''); data = data.replace('\*\/', ''); var dataJson = JSON.parse(data); if (dataJson.logoutUrl != null) { document.location.href = dataJson.logoutUrl; } }, error: function (xhr, status, err) { console.log("error in ajaxLogoutDetailsApi"); } }); }

Aprecia cada pista.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Iba a usar async/await, pero dado que hay un reemplazo extraño antes de que se analice el JSON, volví a la búsqueda de la vieja escuela con "thenables".

 function ajaxLogoutDetailsApi() { const endpoint = 'OIDCGetLogoutDetails'; // Fetch the JSON fetch(endpoint) // This is returned as the first argument // of "then" .then(json => { // Weird replacement stuff const updated = json .replace('\/\*', '') .replace('\*\/', ''); // Parse the JSON const data = JSON.parse(updated); // Set the new page if the condition is met if (data.logoutUrl) { window.location.href = data.logoutUrl; } }) // Catch any errors .catch(error => { console.error('Error:', error); }); }

about 4 years ago · Juan Pablo Isaza 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!