2014년 7월 8일 화요일

Django와 함께하는 Jquery Ajax의 simple한 예제

참고 :
http://stackoverflow.com/questions/5304517/ajax-post-in-django-framework
http://api.jquery.com/jquery.ajax/




ajaxtest.html





Text Area


views.py
 
def ajaxtest(request):
    if request.is_ajax():
        data = "You click " + request.GET['click'] + " button"
        import json
        return HttpResponse(json.dumps({'message':data}), 'application/json')
    return render(request, 'myapp/ajaxtest.html')
    

댓글 없음:

댓글 쓰기