Ajax in Plugins: returns the whole page
you are return simple a string in response variable that is not legitimate on the next line you are returning wp_send_json expect an array but you pass a variable.
you are return simple a string in response variable that is not legitimate on the next line you are returning wp_send_json expect an array but you pass a variable.
You can get the time offset from WordPress Settings using get_option( ‘gmt_offset’ ) So I found the easiest method is to do this: gmdate( ‘Y-m-d H:i:s’, strtotime( get_option( ‘gmt_offset’ ) . ‘ hours’, strtotime( $udata->user_registered ) ) )
add your code with class for ex .loading-wrapper in your header then add this code in your script setTimeout(function(){ $(‘.loading-wrapper’).slideUp();}, 5000);
Yes, like @fuxia says, include wp-load.php to get the WordPress API (wp_nav_menu included) to use. In your case: <?php include ‘../../../../wp-load.php’; This way you did is not wrong but there are better ways to use AJAX in WordPress: https://codex.wordpress.org/AJAX_in_Plugins Be happy, my friend!
There may be browser restrictions preventing autoplaying audio, see this answer https://stackoverflow.com/questions/53058421/local-variable-audio-in-object-method-not-playing You can see this in your browser developer tools console, there will be error like this NotAllowedError: The play method is not allowed by the user agent or the platform in the current context, possibly because the user denied permission. If this sound … Read more
There are two things you should try: WordPress loads jQuery in compatibility mode, so you will need to use the noconflict syntax, ex. jQuery(‘.text-white.follow’).plate();. More information: https://learn.jquery.com/using-jquery-core/avoid-conflicts-other-libraries/ https://digwp.com/2011/09/using-instead-of-jquery-in-wordpress/ If you are using a child theme, you need to call get_stylesheet_directory_uri() instead of get_template_directory_uri(). Parent theme assets are accessed using template, and child theme assets are … Read more
Please simply place commonJs var outside the jQuery function and try again. It will work for you.
Try this. add_action ( ‘wp_head’, ‘custom_script_hook’); function custom_script_hook() { ?> <script type=”text/javascript” src=”https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js”></script> <?php $output=”<script> jQuery(document).ready(() => { $(“div#tm-extra-product-options”).click(() => { console.log(“it working!”) }); }); </script>”; echo $output; }
In my theme functions.php at the end works for me: function themesCharles_enqueue_style() { wp_enqueue_style( ‘my-theme’, get_template_directory_uri() .’/myFiles/myStyle.css’, false ); } function themesCharles_enqueue_script() { wp_enqueue_script( ‘my-js’, get_template_directory_uri() .’/myFiles/myScript.js’, false ); } add_action( ‘wp_enqueue_scripts’, ‘themesCharles_enqueue_style’ ); add_action( ‘wp_enqueue_scripts’, ‘themesCharles_enqueue_script’ );
Does the get-contacts.php script work ok if you load it directly, e.g. in your browser or from the command line, or in some test javascript? Maybe you don’t have the path correct. Instead of providing a partial path you could provide an absolute path. Is the reuse directory in the root of your web space? … Read more