调用使用AJAX的时间间隔后,PHP函数 [英] calling a php function using ajax after interval of time

查看:163
本文介绍了调用使用AJAX的时间间隔后,PHP函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在一个 codeigniter 的项目。我想10秒的时间间隔后执行PHP函数。当用户在10秒后访问特定网页我想,要执行 PHP 功能。在该 PHP 函数我设置了计数器加1到特定的表到数据库。我曾试过用 AJAX ,但没得到想要的结果。请解释一下我用的例子,因为我是新的 AJAX 。在此先感谢...

hi i am working on a codeigniter project. I want to execute a php function after an interval of 10seconds. When a user visits that specific page after 10 seconds i want that php function to be executed. In that php function i have set a counter which adds 1 to the specific table into the database. I have tried using AJAX but didnt get the desired result. Kindly explain me with examples as i am new in ajax. Thanks in advance...

推荐答案

你可以试试这个:

window.jQuery(function(){
var y=setInterval(function() {
        window.jQuery.post(url,{"token": "your_token"},function(res){
        alert(res);
   });   
 }, 10000);
});

这篇关于调用使用AJAX的时间间隔后,PHP函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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