简体   繁体   中英

POST Data to another page of PHP for processing using Ajax using data not received

Sender page

$.ajax({
    type : "POST", // type of method
    url  : "1.php", // your page
    data : { PID : $PID, PQ : $ProductNeed }, // passing the values
    success: function(res) { }
});

Receiver Page

if (isset($_POST['PID'])) {
    $result = mysqli_query($conn, "call herestoredProcedure('".$_SESSION['USERid'])."','".$_POST['PQ']."','".$_POST['PID']."')";
    mysqli_close($conn);
}

_POST Not Receiving data of PID, PQ Indexer. Please help me to solve it.

You have a typo in URL parameter. It's not "1 .php" but "1.php". Also I do not advise you to name php files only by numbers.

I have checked this one and it's working perfectly if you still got the problem try this I think your problem in path or something in my code all the files in same folder so check for that.

callto1.html

<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="UTF-8">

<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>

</head>
<body>

</div>

<script>
var $PID = 1;
var $ProductNeed=2;

$(document).ready(function(){
    $.ajax({
    url : "1.php", // your page
    type : "POST", // type of method
    data : { PID : $PID, PQ : $ProductNeed }, // passing the values
    success: function(res) {
        alert(res);
     }
});
});

</script>

</body>
</html>

1.php

<?php

if(isset($_POST['PID']) && isset($_POST['PQ'])){
    echo "came";
}

?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM