在单击链接后,我使用PJAX加载了一些html。但我需要向链接上的url发送一些自定义数据:
$(document).on('ready pjax:beforeSend', function(event, options) {
options['data'] = $('.fields-on-fly .form-control').serialize();
return $.pjax.click(event,'',options);
});
所以,我使用了beforeSend事件来捕获PJAX之前的触发器,但在将数据注入选项之后该过程时出现了问题。
提示如下:
TypeError: link.tagName is undefined
if (link.tagName.toUpperCase() !== 'A')
jquery....8767812 (line 82, col 1)
当调用$.pjax.click时返回错误。
I found the issue, you only needed to modify the options with the data:
$(document).on('ready pjax:beforeSend', function(event, xhr, options) {
options.data = $('.fields-on-fly .form-control').serialize();
});