One Page Navigation and add_action('wp_ajax_{action} problem

Good Morning,

Looking for a development that will adapt to a functionality (ajax paging of the recent post shortcode) of a client, we have managed to make it work very well and adapt, but on the other hand, when clicking on the menu options, it makes a very rare move scroll!

We are not very clear that it is for development. Because if we deactivate the lines that load it, they still do the same strange scroll

add_action(‘wp_ajax_{action}’, function_name);
add_action(‘wp_ajax_nopriv_{action}’, function_name);

Any suggestion?

Hello Mauro,

I can see the strange scroll. There is a JS syntax error

Uncaught Error: Syntax error, unrecognized expression:

To make sure this is not a side effect of any customization, please try to remove your custom codes and then clear your cache. Check again after that. The error on the console is pointing to a broken file. There is no known issue related to this so we need to check possible root cause on your site.

Let us know how this goes.

Good Morning,

I have removed everything regarding the customization requested by the client and continues to do the same. Another test has been to remove all the extra from the functions.php file that works on other websites and that they were small changes in functionality explained in the forum by you and not even that way stop doing the strange scroll!

Hello Mauro,

I have inspected your page and I am seeing this custom JS code:

jQuery(document).ready(function($){

  /* Overwrite menu action anchors */
  $( document).on('click', '.x-menu > li > a', function(e) {
    e.preventDefault();
    var id = $(this).attr('href') + '-content';

		var section = $(id);
    
    $('html,body').animate({scrollTop: section.offset().top}, 1500);
  })
  
});

This could also be causing the issue. Can you please temporarily remove this code and test your site again? This is to make sure that the weird scrolling issue is not coming from a custom JS code. You may also test for a plugin conflict. You can do that by deactivating all third party plugins, and seeing if the problem remains. If it’s fixed, you’ll know a plugin caused the problem, and you can narrow down which one by reactivating them one at a time.

Kindly let us know how it goes.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.