jQuery ajax empty exeption on wordpress

by sswwqqaa   Last Updated July 15, 2018 15:08 PM

This script works well on standalone site:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
jQuery(document).ready(function(){  
    jQuery.ajax({
             url: 'xxx',
             success: function(data, textStatus, jqXHR ) {
                 alert(jqXHR.responseText);
             },
             error: function(jqxhr, status, exception) {
                 alert('Exception:', exception);
             }
         })
});
</script>

However when I try to use it on WordPress page it returns me an empty exception. What can be causing this behavior and how I can debug this?

(I added the lines below in functions.php)

function include_jquery() {

    wp_deregister_script('jquery');
    wp_enqueue_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js', array(), null, true);

}
add_action('wp_enqueue_scripts', 'include_jquery');

One important remark is that js window.onload stopped working on my WordPress a few days ago and I started using jQuery(document).ready. I don't know why, maybe someone made some changes that I'm not aware of.



Related Questions


How to reset, reinit wordpress wpColorPicker?

Updated August 02, 2017 09:08 AM