[英]Data is not received on PHP page using $.POST() method of jquery
My POST variable at PHP page is always empty still after clicking on submit button. 单击“提交”按钮后,PHP页面上的POST变量仍然为空。 I send data from a javascript page to php page.
我将数据从javascript页面发送到php页面。
Javascript code: Javascript代码:
$('#btnSubmit').click(function(){
if(quantityArray[j] == undefined){
alert("Empty Form can not be submitted!");
}
else {
$.post('insert_man_order.php',{ total_price: quantityArray[j] }, function(data){
alert(data);
});
}
});
The PHP code where i should receive the value of variable total_price is: 我应该收到变量total_price的值的PHP代码是:
if(isset($_POST['total_price'])){
$price = $_POST['total_price'];
}
else{
echo "No data recieved";
}
One more thing here.. I have written alert by passing data into it in $.post function and it works perfect. 还有一件事......我通过在$ .post函数中将数据传递到它来编写警报,它完美无缺。 So if data is received perfectly after passing it to another page than whats the problem in receiving it at another page?
因此,如果数据在传递到另一个页面之后被完美地接收,那么在另一个页面接收数据的问题是什么呢?
Instead of 代替
if (isset($_POST['total_price'])) {
$price = $_POST['total_price'];
}
else {
echo "No data recieved";
}
do this 做这个
if (isset($_POST['total_price'])) {
echo $_POST['total_price'];
}
else {
echo "No data received";
}
you must print the data to make an ajax response. 您必须打印数据以进行ajax响应。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.