在ajax调用中传递php值 [英] Passing php values in an ajax call

查看:120
本文介绍了在ajax调用中传递php值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我正在制作这笔交易的网站.在交易网站的索引页面上,将列出多个交易,每个交易都有其自己的结束日期.

so I'm making this deal website. On the index page of the deal website, there would be multiple deals listed and each deal has it's own end date.

现在,我正在使用此jQuery脚本进行时钟倒计时.

Now, I'm using this jQuery script for the clock countdown.

<script>
$(function () {
    var austDay = new Date();
    austDay = new Date(austDay.getFullYear() + 1, 1 - 1, 26);
    $('#defaultCountdown').countdown({until: austDay});
    $('#year').text(austDay.getFullYear());
});
</script>

这是数据库结构

Product ID           ProductName    End Date

(auto_increment)       (VARCHAR)      DATE

现在,我想我必须将上述jQuery脚本放入while循环中(循环将遍历产品并显示其详细信息)以显示每笔交易的时间.

Now, I guess I would have to put the above jQuery script within a while loop (loop would go through the products, and display their details) to show the clock for each deal.

我如何在jQuery中传递产品ID(例如,产品ID在$ productid变量中),这样我就可以从那里进行mysql查询以获取结束日期.然后时钟显示每笔交易的正确时间.

How would I pass a product id (for example let's say the productid is in the $productid variable) in jQuery, so that I can do a mysql query from there to get the end date..and then the clock displays the correct time for each deal.

欢迎提出任何建议.

推荐答案

您可以使用jquery ajax,因此可以通过jquery ajax从php文件中获取正确的日期并将其设置为$('#defaultCountdown').countdown({until: austDay});.如果您想从php文件中获取日期,那么您可以使用javascript setTimeOut.

You can use jquery ajax, so get correct date from php file via jquery ajax and set it into $('#defaultCountdown').countdown({until: austDay});. If you want get date peridly from php file so u can use javascript setTimeOut.

jquery ajax

设置超时

这篇关于在ajax调用中传递php值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆