Try as I might I can’t get my data outside the function with a global var. I have tried everything that I can think of including window.nuTime without success.
$.ajax({
cache: false,
type: 'POST',
url: 'servertime.asp',
data: {},
success: function (data) {
$('#servertime').html(data);
window.nuTime = data;
//alert(data);
},
error: function (jxhr, msg, err) {
$('#response').append('<li style="color:red">' + msg + '</li>');
}
});
alert(nuTime);
Kolink is right ! You could improve this doing like that :