1

I want to use AJAX in a django website. As far as I know, I can do that via JQuery API, such as $.ajax() and .load(). But I also recognized that there is a very popular 3rd party plug-in for django called Dajax.

So what are the pros and cons for using JQuery Ajax and Dajax respectively?

One thing I found is that when using JQuery Ajax in Django, you should config a url for each Ajax request. The Ajax request will find a python function in your views.py file via this url.

But when using Dajax, you don't need to do so. It seems you can call a python function (directly from your template) in the ajax.py file under project's app directory without config a specific url for it.

I'm not even sure wether this difference I mentioned above is true. This question seems silly. But I'm new to both Django and Ajax concepts. I did some search but the Dajax seems to be poorly documented. So I can not figure it out.

Can anyone help me? Thanks a lot.

Xiao Liang
  • 763
  • 2
  • 7
  • 12
  • Yah, that is also my problem. A beginner here also, personally I choose Ajax because of familiarity although as you stated it is hassle that everytime you take request you need to add it in your urls.py. But I find it comfortable and it works like any other language used it, so more documentation. – Sachi Tekina Mar 12 '15 at 14:35
  • Thank you. I think I will take the same choice. – Xiao Liang Mar 13 '15 at 18:38

1 Answers1

1

I enjoyed using Dajax, some years ago, but now, as the nice Jorge Bastida himself says in the project page, the need is much thinner and using both technologies without any middle layer works just fine.

If you worry about having to write too many views for the dynamic part of your app, just go for a bigger one that behaves differently according to the parameters passed with the ajax call - I'm doing it often on a v1.7 project and, together with the new JsonResponse, everything goest smoothly.

Community
  • 1
  • 1
mccc
  • 2,354
  • 1
  • 20
  • 22
  • Yeah, you are right buddy. The author seems recommend that we should not use the Dajax plug-in any more. The JsonResponse with Jquery AJAX API can be always enough to achieve what I want. Thanks! – Xiao Liang Mar 13 '15 at 18:36