也许我正沉入一个空的玻璃杯中,或者我在这个项目上花费了太多的时间,但它是这样的:我想从一个htm文件中使用jquery调用一个php脚本。
我的jquery代码:
$.ajax({
type: "POST",
url: "localhost/calculate/vr4/getAmount.php",
data: "from="+ from_date +"&enddate=" + end_date,
success: function(info){
alert("test info : " + info);
}
});
php脚本:
$testdate=$_POST['from'];
if ($testdate==NULL)
{
echo "No text";
}
else
{
echo "a date";
}
什么都没有发生,我在url中注意到了:
http://localhost/calculate/vr4/summary_q.php?consult_range.x=30&consult_range.y=5
这些参数(consult_range)是我将单击事件与jquery绑定的类名。有什么建议吗?我尝试了这个论坛和其他论坛上的几个代码示例,我得到了相同的结果。希望有人接电话,我知道有点晚了。
发布于 2012-06-19 14:00:37
试试这条路
$.ajax({类型:"POST",url:"http://localhost/calculate/vr4/getAmount.php",data:"from="+ from_date +"&enddate=“+ end_date,成功:函数(信息){alert(”测试信息:“+ info);} });
或
$.ajax({类型:"POST",url:“vr4/getAmount.php t.php”,data:"from="+ from_date +"&enddate=“+ end_date,成功:功能(信息){alert(”测试信息:“+ info);} });
发布于 2012-06-19 12:36:46
你正在以GET格式传递数据,我猜因为你在php中使用了$_POST,所以你得到了一个错误,因为没有Post数据。在ajax调用中,我认为您需要将数据作为对象进行传递。但为了检查我是否正确,请将$_POST更改为$_GET
更新
在ajax调用cange data中,使用
data: {from: from_date, enddate: end_date}
https://stackoverflow.com/questions/11094345
复制相似问题