By dennari on
I've got a huge problem understanding this one thing. How do I use the Drupal framework (the database access in particular) from within the PHP handler of an AJAX session? I mean, doesn't this mean executing the whole of Drupal everytime an AJAX request comes? I've been dwelling into the contents of modules incorporating AJAX techniques with db access and still can't figure out how this is possible.. I've also read the AJAX part of the module developer handbook to no avail.. Can someone please explain me. Thanks a lot.
-Ville
Comments
Ajax handler is a module function
Yes, this is what's generally done. See for example
function upload_js()and its menu item defined inupload_menu().Me is a morron...
when it comes to AJAX and all that, but this sounds to me like it is pretty in-efficient..
Or, am I not getting this right?
---
Damn, I wish i could sprinkle AJAX, JSON and unobtrusive javascript into core...
Well...
For AJAX PHP handlers we generally need access to APIs available only through a Drupal bootstrap.
What if just a little bit is needed
Okay, that's what I was afraid. So the practice used is that the xmlhttprequest object calls drupal the same way a normal link would (meaning www.mydrupalsite.com/?=ajax/dothing), which of course fires up everything possible. Right?
Most of the time this seems to be too much for the needs of an ajax php handler. To me at least.
Is there a way to do this so that maybe only the database connection would be fired and no more? Or is the general opinion that it's not a big deal the load up the whole thing anyway? How efficient it actually is? Thanks again.
the way it is
That's just the way it is. I would guess that you are going to need all the features provided by bootstrap anyways as your ajax is probably answering a dynamic request. The bootstrap is very efficient and probably the most tuned part of drupal so I don't think I'd worry about it too much.