如何在ajax javascript中设置定时器控件?

时间:2012-05-16 08:57:42

标签: javascript ajax timer

Hai我的应用程序试图与服务器通信,所以我在ajax中调用webservice,现在我想在ajax.anybody中设置时间间隔,直接指导我

$(document).ready(function () {
    $("#btn").attr("disabled", true);
    //waitingDialog({});
    document.addEventListener("deviceready", onDeviceReady, false);

    function onDeviceReady() {
        var imei2 = '';
        imei2 = device.uuid;
        checkConnection_inonload(imei2);
    }

    function checkConnection_inonload(imei2) {
        var networkState = navigator.network.connection.type;
        alert(networkState);
        var states = {};
        states[Connection.WIFI] = 'WiFi connection';
        if (states[networkState] == 'WiFi connection') {
            $.ajax({
                cache: false,
                async: true,
                type: "GET",
                dataType: "json",
                url: "http://xxxx/Service1.svc/GetKeepMeStatus",
                data: {
                    IMEINO: imei2
                },
                contentType: "application/json;charset=utf-8",
                success: function (r) {
                    //closeWaitingDialog();
                    //alert(r);
                    if (r == "status") {}
                });

1 个答案:

答案 0 :(得分:0)

我在我的ajax函数中设置超时timeout:3000它现在正在工作。