• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

137
Views
¿Cómo hacer eco de los datos ajax con la ayuda de php?

Intenté imprimir los datos que ingresó el usuario y transferirlos a través de ajax e intenté imprimirlos o repetirlos con la ayuda del código php, pero no pude hacerlo. enter code here este es mi código:

 `<html> <head> <title> test ajax </title> <script src = "jquery.js"></script> </head> <body> <h2>test button</h2><br> <form> <input type = "text"id = "a"><br> <input type = "button" id = "b" value = "display"> </form> <script> $(document).ready(function(){ $('#b').click(function() { let a = $('#a').val(); alert(a); $.ajax({ type: "POST", url: "same_file.php", data: {c: a}, success: function() { } }); }); }); </script> </body> </html> <?php extract($_POST); if(isset($_POST["c"])) { echo $_POST["c"]; } ?>

`

Creo que tengo el problema con el código php. por favor dame alguna solución.

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

0

Pruébalo así

este es tu html

 <html> <head> <title> test ajax </title> <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> </head> <body> <h2>test button</h2><br> <form> <input type = "text" id = "a" > <br> <input type = "button" id = "b" value = "display" > </form> </body> </html> <script> $(document).ready(function(){ $('#b').click(function() { let a = $('#a').val(); //alert(a); $.ajax({ type: "POST", url: "same_file.php", data: {c: a}, success: function(response) { alert(response); } }); }); }); </script>

Este es su mismo_archivo.php

 <?php //extract($_POST); code works even without this if(isset($_POST["c"])) { echo $_POST['c']; } ?>

No estoy seguro de si su llamada a la biblioteca jquery está bien, así que llamé a la de la web. Además, su éxito: función () no estaba haciendo nada, por lo que no recibió nada.

Además, formatee siempre su código con alguna sangría para que pueda ser más fácil de leer y comprender por otros.

about 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error