javascript - .load ajax not working properly whitin wordpress theme

723

I try to use the .load function in my Wordpress theme , the code I use is previously tested in an HTML theme and it worked well .

When I'm using it in the js file of the Wordpress theme, it's display nothing.

Can someone tell me what I'm doing wrong ?

Thank you all in advance

jQuery and .js are loaded in functions.php

function atito_theme_scripts() {
wp_enqueue_style( 'atito-theme-style', get_stylesheet_uri() );

wp_enqueue_script( 'atito-theme-jquery', get_template_directory_uri() . '/js/jquery-2.2.2.min.js', array(), '20130114', true );

wp_enqueue_script( 'atito-theme-atito', get_template_directory_uri() . '/js/atito.js', array(), '20130114', true );
}

atito.js

var auto_refresh = setInterval(
function ()
{
jQuery('#auto').load('load.php').fadeIn("slow");
}, 100); // refresh every 100 milliseconds

HTML

<div id="auto"></div>

load.php

<p>test ajax</p>
32

Answer

Solution:

Dont use$ on wordpress codes. use onlyjQuery

<script type="text/javascript">
var auto_refresh = setInterval(
function ()
{
jQuery('#auto').load('load.php').fadeIn("slow");
}, 100); // refresh every 100 milliseconds
</script>

<div id="auto"></div>

People are also looking for solutions to the problem: apache - Laravel thinks that my PHP version does not meet their minimum requirement even if it isn't

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.