admin管理员组文章数量:1426953
I am initializing wp_localize_script after enqueueing scripts like that
wp_enqueue_script('main',get_template_directory_uri().'/js/mains.js','','1.1',true);
wp_localize_script( 'ajax-pagination', 'ajaxpagination', array(
'ajaxurl' => admin_url( 'admin-ajax.php' )
));
but i am unable to get it in jquery file/code jquery code is
(function($) {
$(document).on( 'click', '.page-numbers', function( event ) {
event.preventDefault();
$.ajax({
url: ajaxpagination.ajaxurl,
type: 'post',
data: {
action: 'ajax_pagination'
},
success: function( result ) {
alert( result );
}
})
})
})(jQuery);
on clicking i am seeing the error ajaxpagination is not defined , what can be the possible solutions for this ?
I am initializing wp_localize_script after enqueueing scripts like that
wp_enqueue_script('main',get_template_directory_uri().'/js/mains.js','','1.1',true);
wp_localize_script( 'ajax-pagination', 'ajaxpagination', array(
'ajaxurl' => admin_url( 'admin-ajax.php' )
));
but i am unable to get it in jquery file/code jquery code is
(function($) {
$(document).on( 'click', '.page-numbers', function( event ) {
event.preventDefault();
$.ajax({
url: ajaxpagination.ajaxurl,
type: 'post',
data: {
action: 'ajax_pagination'
},
success: function( result ) {
alert( result );
}
})
})
})(jQuery);
on clicking i am seeing the error ajaxpagination is not defined , what can be the possible solutions for this ?
Share Improve this question asked Jun 1, 2019 at 15:25 FluttererFlutterer 1159 bronze badges1 Answer
Reset to default 1Change the first param of wp_localize_script
to same as the handle of your main script file.
main
in this case.
本文标签: pluginsissue in wplocalizescript
版权声明:本文标题:plugins - issue in wp_localize_script 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745445116a2658629.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论