here is my code in Jquery and Asp.net Unable to get a correct ANS as I am getting from jquery?
Posted
by ricky roy
on Stack Overflow
See other posts from Stack Overflow
or by ricky roy
Published on 2010-04-09T16:14:31Z
Indexed on
2010/04/09
16:23 UTC
Read the original article
Hit count: 316
unable to get the correct Ans as i am getting from the Jquery I am using jquery.countdown.js
here is my code
[WebMethod]
public static String GetTime()
{
DateTime dt = new DateTime();
dt = Convert.ToDateTime("April 9, 2010 22:38:10");
return dt.ToString("dddd, dd MMMM yyyy HH:mm:ss");
}
html file
<script type="text/javascript" src="Scripts/jquery-1.3.2.js"></script>
<script type="text/javascript" src="Scripts/jquery.countdown.js"></script>
<script type="text/javascript">
$(function() {
var shortly = new Date('April 9, 2010 22:38:10');
var newTime = new Date('April 9, 2010 22:38:10');
//for loop divid
///
$('#defaultCountdown').countdown({
until: shortly, onExpiry: liftOff, onTick: watchCountdown, serverSync: serverTime
});
$('#div1').countdown({ until: newTime });
});
function serverTime() {
var time = null;
$.ajax({
type: "POST",
//Page Name (in which the method should be called) and method name
url: "Default.aspx/GetTime",
// If you want to pass parameter or data to server side function you can try line
contentType: "application/json; charset=utf-8",
dataType: "json",
data: "{}",
async: false,
//else If you don't want to pass any value to server side function leave the data to blank line below
//data: "{}",
success: function(msg) {
//Got the response from server and render to the client
time = new Date(msg.d);
alert(time);
},
error: function(msg) {
time = new Date();
alert('1');
}
});
return time;
}
function watchCountdown() { }
function liftOff() { }
</script>
© Stack Overflow or respective owner