Hi!
I'm trying pass one argument from JS to a View. If I type this in at the Views preview, it works fine and I get some result. By passing the same chars (I've tried it with colsole.log()) I've got the "empty result".
Here is my JS code:
var someDate = $(this).attr('id').slice(7,17); // the result format is: 2017-03-03, and it works in the preview
$.ajax({
url: Drupal.settings.basePath +'/views/ajax',
type: 'POST',
data: {
view_name: 'naptar',
view_display_id: 'block_spec',
args: someDate,
},
dataType: 'json',
success: function(response) {
if (response[1] !== undefined) {
var viewHtml = response[1].data;
$('#block-views-naptar-block-2').html(viewHtml);
}
},
error: function(data) {
$('#block-views-naptar-block-2').html('<p>An error occurred...</p>');
}
});
With Firebug I see so, that my AJAX POST is
args: 2017-02-24
view_display_id: block_spec
view_name: naptar
the URL looks like view_name=naptar&view_display_id=block_spec&args=2017-02-24, but in the JSON response 0 -> settings -> views -> ajaxViews -> view_dom_id:xxx -> view_args is empty.
What do I wrong?
Thanks
Comments
Comment #2
pal_ur commentedThere is the mistake:
In
data {}useview_argsinstead ifargs.Comment #3
pal_ur commented