Override views/ajax path

/**
 * js file
 */
 
(function ($) {
  /* this code stole from ajax_view.js , just use this to override the ajax path */
  if (Drupal.views != undefined) {
    Drupal.views.ajaxView.prototype.attachPagerLinkAjax = function(id, link) {
      var $link = $(link);
      var viewData = {};
      var href = $link.attr('href');
      $.extend(
        viewData,
        this.settings,
        Drupal.Views.parseQueryString(href),
        Drupal.Views.parseViewArgs(href, this.settings.view_base_path)
      );
      $.extend(viewData, Drupal.Views.parseViewArgs(href, this.settings.view_base_path));
 
      this.element_settings.submit = viewData;
      if (this.element_settings.submit['view_name'] == 'yourviewname') {  //if viewname matched
        this.element_settings.url = '/result_ajax';  //change views/ajax to your ajax path
        var query = $('#modulename-ajax-compare-result-form').serialize();  //add any data you want to pass before ajax call
        this.element_settings.submit['data'] = query;
      }
      this.pagerAjax = new Drupal.ajax(false, $link, this.element_settings);
    };
  }
})
Help Share this Article