Hello,
I am new to JQuery. I'm trying to get a JSON response back from my
django view. However, I guess my data never gets loaded
successfully. Does anybody know what I'm doing wrong?
<script>
$(document).ready(function(){
$("#first").click(function(){
$.getJSON("/mysite/myajax", function(data) {
alert("Here");
});
});
});
</script>
////
def myajax(request):
a = Testimonial.objects.all()[:3]
response_dict = {}
response_dict.update({'a': a})
return HttpResponse(simplejson.dumps(response_dict),
mimetype='application/javascript')
///////////
Whenever I access this page and click on my div that contains the id
'first'...nothing happens. I should see an alert that says 'Here'.
Any Suggestions on what I'm doing wrong?
Thanks