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

181
Views
Pasar variable de JS usando ajax a PHP variable indefinida

Quiero pasar la variable rating_index al código PHP y enviarlo a la base de datos. Rating_index está configurado. No pasaré el código aquí porque es largo, pero justo antes de AJAX i console.log (rating_index) y tiene valor (int). Agregar revisión es un botón que, después de hacer clic, debe enviar una variable. En js script estoy usando AJAX:

 $('#add-review').click(function(){ $.ajax({ url:"rating-data.php", method:"POST", data: { rating_index: rating_index }, success:function(data) { console.log(data); } }) }

en mi archivo php rating-data.php:

 <?php include 'connection.php'; echo "work"; echo $_POST["rating_index"]; ?>

Obtuve un archivo console.log ('trabajo') de un archivo PHP y este error: Aviso: Índice indefinido: rating_index en /Applications/XAMPP/xamppfiles/htdocs/bookwarm-app/rating-data.php en la línea 4

Entonces está llegando a mi página php pero la variable no está pasando correctamente.

Estaba intentando todo y no tengo idea de qué está mal y por qué esta variable no está definida en el archivo php. gracias por cualquier pista

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

0

Este es el problema en su código, señor

 $user_name = $_GET["user_name"]; $user_rating = $_GET["rating_index"]; $user_review = $_GET["user_review"];

¿Estás haciendo una solicitud $_POST de Ajax y en el archivo php estás obteniendo valores de $_GET...?

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!