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

254
Views
El método Ajax .post() no envía datos al servidor

Tengo 2 páginas web llamadas test1.html y test1.php . Estoy enviando algunos datos como pares clave/valor usando el método ajax .post(), pero parece que no llega al lado del servidor porque recibo el siguiente error:

Advertencia: variable no definida $nombre en C:\xampp\htdocs\WebMid2Practice\ajax\test1.php en la línea 6

Advertencia: Variable no definida $edad en C:\xampp\htdocs\WebMid2Practice\ajax\test1.php en la línea 7

Aquí está mi código:

prueba1.html

 <!DOCTYPE html> <html> <head> <title>Ajax</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js" ></script> <script> $(document).ready(function() { $("#load").click(function() { var txtName = $("#name").val(); var txtAge = $("#age").val(); $.post("test1.php", {name:txtName, age:txtAge}, function(data) { $("#result").html(data); }); }) }); </script> </head> <body> <h1>Ajax Practice</h1> <div class="result"></div> Enter Name: <input type="text" id="name"><br> Enter age: <input type="text" id="age"><br> <button id="load">Send request to test1.php</button> </body> </html>

prueba1.php

 <?php if (isset($_REQUEST['name']) && isset($_REQUEST['age'])) { $name = $_REQUEST['name']; $age = $_REQUEST['age']; } echo "Name entered is: " .$name; echo "Age: " .$age; ?>
over 4 years ago · Santiago Trujillo
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!