this is my template(profile.html):
<input id="postButton"type="button" value="share" onclick="Dajaxice.social.dajaxice_example(my_callback)" />
here is my ajax.py :
from django.utils import simplejson
from dajaxice.decorators import dajaxice_register
from social.models import * # my database
@dajaxice_register
def dajaxice_example(request):
user = User.objects.get(email="email@domain.com")
return simplejson.dumps({'message':user.firstName})
and here is my javascript code that alert the page :
function my_callback(data){
alert(data.message);
}
when I click the button i must waiting for response from database that find the User
that its email
is example@domain.com
how can I insert some funny gif ajax image for showing to user that process is running.thanks
EDIT:
I also add this lines to template and javascript file but ajaxStart
seems that doesn't work:
<div id="wait" style="display:none;"><img src={% static 'social/img/ajax.gif' %} /><br>Loading..</div>
and in js:
$(document).ready(function(){
$(document).ajaxStart(function(){
$("#wait").css("display","block");
});
$(document).ajaxComplete(function(){
$("#wait").css("display","none");
});
});