JQuery & Drupal : setting content thru a GET request

Below you can find an example of some JQuery code that you can use to do the same as described in a previous article. I’ve stopped using the previous code, as it had too many downsides. After getting to know the power of JQuery, I have to say that it’s much better. AND it’s already included in the drupal distribution.

Example

$(document).ready(
  function(){
    $("select").change(function () {
      var about = this.value;
      var uri = '/my/page/' + about;
      $.get(uri, function(data) {
        $("#div-with-updated-data").html(data);
      });
    })
 }
);

NOTE: Don’t try to use mooscript, scriptalicious, … or any other framework that doesn’t extent JQuery within your drupal. It will give you a lot of “function unkown” situations. 😉

Advertisements

2 thoughts on “JQuery & Drupal : setting content thru a GET request

  1. OK. I bite. I don’t get it, where do I put this? In a script tag? How do I access it? What’s the format of the data?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s