jquery插件定时器ajax调用

时间:2011-06-30 00:14:32

标签: jquery jquery-plugins timer

我有ajax称我需要每3秒触发一次,寻找jquery i found this plugin 的插件,但我不能让它工作。有人可以帮助我吗?请参阅下面的代码

$(document).ready(initialize);

function initialize(){
$.ajax({
        async: false,
        type: "POST",
        url: "MapZone.aspx/addingData",
        data: "{indicators: '" + 'probando' + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: loadMarkers
    }).everyTime(1000, 'controlled');

}

function loadMarkers(data) {
  //i do stuff here
}

1 个答案:

答案 0 :(得分:2)

我认为你不需要插件。您可以使用setInterval每3000毫秒进行一次AJAX调用:

function initialize() {
    setInterval(function () {
        $.ajax({
            async: false,
            type: "POST",
            url: "MapZone.aspx/addingData",
            data: "{indicators: '" + 'probando' + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: loadMarkers
        });
    }, 3000);
}