javscript delay output
- by tazim
I have written some code to display server's current date and time on browser every time user clicks the button . I have done this using ajax in django with the help of jquery.
Now my, problem is I have to continously display the date and time once the button is clicked .
Some Sample code or utilities allowing such kind of delay will be helpful .
Thanks in advance
The template is :
$(document).ready(function()
{
$("button").click(function()
{
$.ajax({
type: "POST",
url :"/showdate/",
datatype: "json ",
success : function(data){
var s = data.currentdate;
var sd = s
$(sd).appendTo("div");
}
});
});
});
<button type="button">Click Me</button>
<div id="someid"></div>
The view function is :
def showdate(request):
now = datetime.datetime.now()
string_now = str(now)
return_dict = {'currentdate':string_now}
json = simplejson.dumps(return_dict)
return HttpResponse(json,mimetype="application/json")