Making Ajax calls with jquery in WordPress
I am trying to implement this script on a page in WordPress to make ajax calls with jquery to load content contained in the file /ajax/load.php to the <div id="result"> container.
<div id="result" class="functions">
</div>
<div>
<input type="submit" value="Next" id="load_basic" />
</div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
$.ajaxSetup ({
cache: false
});
var ajax_load = "<img class='loading' src='img/load.gif' alt='loading...' />";
// load() functions
var loadUrl = "ajax/load.php";
$("#load_basic").click(function(){
$("#result").html(ajax_load).load(loadUrl);
});
</script>
The script works fine for me on a static hand-coded page, but I can't get working in WordPress.
I've tried reading the WordPress codec and other sources and from what I gather I need to add the wp_enqueue_script function to function.php to get ajax working in WordPress.
I am new to WordPress and ajax, and unfortunately I am not sure how to implement wp_enqueue_script.
Can anyone provide some help on how to get this ajax load script working in WordPress?
|