issue in wp_localize_script

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 ?

Read more here:: issue in wp_localize_script

Leave a Reply

Your email address will not be published. Required fields are marked *