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

353
Views
¿Cómo se falsifica una solicitud .xhr usando fetch() y Vanilla JavaScript?

Estoy trabajando para eliminar todo el jQuery de un sitio web y reemplazarlo con JS simple. En primer lugar, no tengo control sobre el backend. No puedo cambiar nada del lado del servidor. Entonces la API ejecutará mi solicitud a través de esto:

 def render_created_comment(comment) if request.xhr? render :partial => "comments/postedreply", :layout => false, :content_type => "text/html", :locals => { :comment => comment } else redirect_to comment.path end end

Esta es una configuración para que el sitio pueda procesar solicitudes js normales y aquellos que se niegan a usar JS y tratan el sitio como si fuera 1999.

Entonces, necesito escribir una solicitud de recuperación que finja ser un .xhr, ¿es eso posible? Ya puedo enviar los datos del formulario, pero termino con la redirección que estoy tratando de evitar.

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

0

Cuando use fetch() agregue el encabezado X-Requested-With: XMLHttpRequest . Esto es esencialmente lo que hacen jQuery y otros marcos.

 fetch(url, { headers: { 'X-Requested-With': 'XMLHttpRequest' } }
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!