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

139
Views
Ajax llamando a PHP y obteniendo valor de retorno

No usé Javascript -> Ajax -> PHP -> Javascript antes y estoy luchando por recuperar el valor de retorno. Ajax está llamando al PHP, pero todo lo que obtengo es el HTML de la página web. ¿Alguien puede ver lo que estoy haciendo mal?

JavaScript: -

 onChange: function(value, text, $selectedItem) { jQuery.ajax({ url : 'index.php', type : 'post', data : { action: 'getTest', param : text }, success: function(result){ console.log('Sucess',result); }, failure: function(result){ console.log('Failed'); } }); }

PHP: -

 $_action = isset($_Post['action']) ? $_Post['action'] : '0'; if ($_action == 'getTest') { $test = $_Post['param']; echo $test; exit; }

Como dije, RESULT parece contener el HTML de la página y no el valor de cadena esperado.

Gracias

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

0

Su variable de publicación está en minúsculas. Sin embargo, la variable debe estar en mayúsculas ( $_POST ). Por lo tanto, su php no ingresará en la declaración if.

https://www.php.net/manual/es/reservado.variables.post.php

Para depurar este tipo de problemas, comience a registrar variables como $_action y verifique si su valor es el que espera que sea. Luego verifique si la declaración if realmente se dispara, etc. hasta que encuentre el 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!