AJAX framework or native jquery?
Hello to the forum!
So, I am a little confused about this topic. Drupal 7 provides a AJAX framework which in a nutshell is how to make AJAX requests without writing javascript. For example lets say i have a link somewhere in a block which loads the most recent articles. It's not a real problem but you get the idea. I normally would write the appropriate js file using jquery's AJAX methods and so on.
The question is why i should prefer the framework instead of native jquery and vise versa ... ? There aren't many tutorials about AJAX in drupal 7 out there...
What's your opinion?
Thank you
To add ajeancharles3's answer, there are a few things you get from using Drupal for this instead of writing your own jQuery:
- Often, the implementation is simpler (once you know what it is).
- The jQuery can be modified by other modules through the use of alter hooks.
That said, there are still times where you'll end up writing your own jQuery / JavaScript, and that's totally fine. As long as it's in a standard place, using the standard enclosures (see 3:22 - How to use the dollar sign as an alias for the jQuery object), that should be enough to guide other developers to the right place to make their modifications.
Cheers,
Chris
Key concept: "Graceful degradation" if javascript is disabled the functionality will still work as long as you code it the right way using the framework.
If you use JQuery to code your functionality, you are on your own, if javascript does not work. your functionality does not exist at the server side level