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

138
Views
very simple ajax doesn't work

I am fiddling with ajax, the following doesn't work:

$(document).ready(function() {
  $("button").click(function() {
    $.post("\tests\test1.php", function(data) {
      alert(data)
    });
  })
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

<button>Click</button>

with test1.php

<?php

echo "Yes";

?>

The url is with respect to htdocs, so correct. Please point out the error.

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You are using an incorrect url: never use "\tests\test1.php"

Instead "/tests/test1.php" is the correct approach.

So your code becomes:

$.post( "/tests/test1.php", function( data ) {
    alert(data);
});

I would also recommend you to use the full URL exaple:

http://example.com/tests/test1.php

instead of /tests/test1.php. (although not required but considered as a good approach.)

about 4 years ago · Santiago Trujillo 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!