I'm using jquery countdown plugin with the following code.
$('#countbox').countdown({
layout:'<b>{d<}{dnn}:{d>}'+ 
    '{hnn}: {mnn} : {snn} </b>',
timeSeparator: ':', 
onExpiry: sold,
onTick: highlight,
serverSync: serverTime
});
function serverTime(pid) { 
    var time = null; 
    $.ajax({
        url: 'ajax_countdown', 
        async: false,
        data: ({pid:pid}),
        dataType: 'text', 
        success: function(text) { 
            time = new Date(text); 
        },
         error: function(http, m开发者_运维知识库essage, exc) { 
            time = new Date(); 
    }}); 
    alert(time);
    return time; 
}
Question 1: using this I'm calling the function serverTime and I want to pass the value pid to the method. How do I achieve this ?
Question 2 is related to the javascript Date function 
$d4 ="2011,01-1,11,23,31,32";
alert(new Date(<?php echo $d4; ?>));
when I run the above code I get following result
Tue Jan 11 2011 23:31:32 GMT+0530 (India Standard Time)
But, the ajax call (as above) also returns the same result, yet in this case when I alert, I receive the following response
Invalid Date
alert(time);
Why is this different in the second case and how can I alter my code to receive my desired behaviour?
The "alert" fires before the ajax answer returns... include it into the success function... or call a function from success..
function serverTime(pid) { 
    var time = null; 
    $.ajax({
        url: 'ajax_countdown', 
        async: false,
        data: ({pid:pid}),
        dataType: 'text', 
        success: function(text) { 
            time = new Date(text); 
            alert(time);
            return time; 
        },
         error: function(http, message, exc) { 
            time = new Date(); 
    }}); 
}
i got answer myself for this Question 1: using this i 'm calling function serverTime . here i want to pass the value pid to the method.how to do this ?
The code snippet not yet tested but i hope it will work.
 $('#countbox').countdown({
    layout:'<b>{d<}{dnn}:{d>}'+ 
        '{hnn}: {mnn} : {snn} </b>',
    timeSeparator: ':', 
    onExpiry: sold,
    onTick: highlight,
    serverSync: function() { serverTime(pid); }
    });
function serverTime(pid) { 
    alert(pid);
}
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论