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

239
Views
isset($_POST['value']) data is not recieved by php

I'm trying to send some values from a javascript file with POST to a php page.

AJAX code:

let inputval = $input.val();
$.ajax({url: "../checkout/test.php", type : 'post', data : {'inputval': inputval}, success: 
function(data){ 
                console.log(data);
              }

PHP code

 if (isset($_POST['inputval'])){
        $result = $_POST['inputval'];
        echo json_encode($result);
    }
    else {
        echo 'Not recieved';
    }

When I check it in networks all is as expected, but when I open the actual page the data is not recieved.

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

0

when I open the actual page the data is not recieved.

First you make a POST request using JavaScript. The data is visible in the network tab. It it sent to the PHP program. The PHP program responds. The response is logged to the console.

Then you "open the actual page". This is a new request. It is not the POST request with the data. $_POST will be empty this time. The response will be the response to the new request, not the previous POST request. Since the content of the response depends on $_POST and that has changed, this response is different.

If you want to store the inputval data from the first request and then display it in subsequent requests you need to explicitly store it somewhere (such as a database or a session variable) and then check that location for data when you receive the subsequent request.

The logic would run something like:

IF this is a POST request
    store the inputval in the session
    send a confirmation message to the client
ELSE IF the session contains an inputval
    send it to the client
ELSE
    send a message to say that there is no data to the client
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!