0

I am trying to access content, that is provided via and can be filtered via a view. I want to load this content dynamically with Ajax. My problem now is, that I can access the view without problems using the following ajax-call:

$.ajax({
    url: Drupal.settings.basePath + 'views/ajax',
    type: 'post',
    data: {
        view_name: 'search',
        view_display_id: 'block_1',
        filterName: value
    },
        success: function(data,jqxhr) {
            $("#ajax-test").html(data)
            console.log(data[1])
        },
        error: function(error) {
            console.log(error)
        }
    });

This works fine, but it ignores the value of filterName (Which corresponds to the according input in the view form). Unfortunately using Better Exposed Filters and Links is not an option since I need to access many filters at once.

Also building an URL like so:

$.get(Drupal.settings.basePath + 'views/ajax/search/block_1/', "filterName[0]=filterValue" ,resultFunction);

did not work for me. Thanks ahead for any pointers!

1 Answer 1

0

If you call a display_id of block_1 the block does not have the exposed_form created to be evaluated by default in Views (views blocks cant have exposed forms out of the box) -- so your AJAX views calls knows nothing about any exposed form.

You need to either call a Views Page url where the exposed form is set on the page. Or, you need to use Views hooks to create/attach the exposed form to the View when your Ajax call is made.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.