1 year ago
#389023
Shibbir
On the popup form - Why Form submission is loading the page
On this page https://spa.micra-anglia.gr/ if you go to "Purifying Detox face & body ritual" section and click on this title you can see that a sidebar is showing. On this sidebar, I am calling ajax to get some content.
On this content, I have a WordPress form that is showing using shortcode.
Now, If I press the Submit button (Blue one) it's reloading the page. Why?
but if you check the same form on this page: https://spa.micra-anglia.gr/test-form/ you can see the page is not loading.
Can you tell me what is happening here?
My JS code for the pulling content:
jQuery(document).ready(function($){
$(document).on('click','.custom-ajax-link,.open_sidebar_post, .post-title a,.post .post-item .post-thumbnail a',function(e){
loadPostEvent(e);
return false;
});
function loadPostEvent(event){
var el = $(event.currentTarget);
var url = el.attr('href');
if(typeof url == "undefined" || url === ''){
url = el.attr('data-href');
if(typeof url == "undefined" || url === '') {
var classList = el.attr('class').split(/\s+/);
$.each(classList, function (idx, item) {
if(item.indexOf('MAINURL') >=0){
url = item.replace('MAINURL',main_url).trim();
}
})
}
}
$('.sidebar-post').empty();
$('.sidebar-post').append('<span class="close-sidebar-post"></span><span class="loading-circle"><i class="fas fa-circle-notch fa-spin"></i></span>');
if(!$('body').hasClass('open-right-sidebar')){
var scrollbarWidth = getScrollbarWidth();
if(scrollbarWidth > 0){
$('body').css('padding-right',scrollbarWidth+'px');
}
$('body').addClass('open-right-sidebar');
}
$.ajax({
url: '<?php echo admin_url('admin-ajax.php')?>',
data: {action: 'load_sidebar_post', url: url},
type: 'POST',
success: function(res){
if(res !== ''){
if(!$('#vc_accordion_script-js').length){
$('<script>')
.attr('id', 'vc_accordion_script-js')
.attr('src', '<?php echo get_site_url()?>/wp-content/plugins/js_composer/assets/lib/vc_accordion/vc-accordion.min.js?ver=6.7.0')
.appendTo('head');
}
$('.sidebar-post').empty();
$('.sidebar-post').append('<div class="sidebar-content portfolio-template-default single single-portfolio"><span class="close-sidebar-post"></span>'+res+'</div>');
window.vc_js();
console.log(Kalium);
galleryContentPost();
Kalium.Media.VideoJS.initVideoElements();
}
}
})
}
});
javascript
jquery
0 Answers
Your Answer