Bir ajax sayfa için url almak nasıl?

0 Cevap php

I'm pretty new to ajax and I applied it succesfully to a Drupal site. But I was wondering, how do I get an URL to a page where part of the content is loaded through ajax. Is this even possible? The JSON object is retrieved on click, so how do I make it work when retrieving a certain URL? I realize this is a very broad questionany, any help would be greatly appreciated. Thanks in advance!

Benim JS bu gibi görünüyor:

  Drupal.behaviors.ajax_pages = function (context) {
  $('a.categoryLink:not(.categoryLink-processed)', context).click(function () {
    var updateProducts = function(data) {
      // The data parameter is a JSON object. The films property is the list of films items that was returned from the server response to the ajax request.
      if (data.films != undefined) {
        $('.region-sidebar-second .section').hide().html(data.films).fadeIn();
      }
      if (data.more != undefined) {
        $('#content .section').hide().html(data.more).fadeIn();
      }

    }
    $.ajax({
      type: 'POST',
      url: this.href, // Which url should be handle the ajax request. This is the url defined in the <a> html tag
      success: updateProducts, // The js function that will be called upon success request
      dataType: 'json', //define the type of data that is going to get back from the server
      data: 'js=1' //Pass a key/value pair
    });
    return false;  // return false so the navigation stops here and not continue to the page in the link
}).addClass('categoryLink-processed');
}

0 Cevap