JavaScript file successfully registered but does not render correctly

You were using action to enqueue script, instead you need to use filter hook. As, you are adding a new script to the scripts call. However, if you used action hook for the wp_head call it works there. <?php add_filter(‘wp_enqueue_scripts’, ‘colorboxJS’); function colorboxJS() { wp_enqueue_script( ‘colorbox’, get_stylesheet_directory_uri() . ‘/colorboxJSfile.js’, array(‘jquery’) ); } ?>

js code not stored in database currectly

If you search WordPress core for &lt; or &gt; you will find the function _wp_specialchars in /wp-includes/formatting.php Then if you search for _wp_specialchars you will see it is used in esc_js (as well as esc_html and esc_attr) so do not use esc_js, escaping is mostly for output anyway. Further search results show that in /wp-includes/default-filters.php … Read more

jQuery ajax empty exeption on wordpress

As I said in the comments. The problem was on api side. Error: (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). How to solve: Add this to .htaccess of api <IfModule mod_headers.c> Header set Access-Control-Allow-Origin: myUrl </IfModule>

JavaScript errors

Try & paste this below code your active theme functions.php file add_action( ‘wp_enqueue_scripts’, ‘load_jquery_fix’, 100 ); function load_jquery_fix() { if ( ! is_admin() ) { wp_deregister_script( ‘jquery’ ); wp_register_script( ‘jquery’, ( “//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js” ), false, ‘1.11.3’ ); wp_enqueue_script( ‘jquery’ ); } }

Bad Request when adding new post via ajax form

Finally found the problem. The action: save_post was missing from data in ajax call. This code works: <script> jQuery( document ).ready(function() { jQuery(‘input[type=button]’).on(‘click’, function() { var ajaxurl = “<?php echo admin_url(‘admin-ajax.php’); ?>”; jQuery.ajax({ type: “POST”, data: { data:jQuery(‘.event-form’).serialize(), action: ‘save_post’ }, url: ajaxurl, success: function(result) { console.log(‘data sent!’); console.log(‘sent to: ‘ + templateDir + loadUrl … Read more