I'm trying to learn using AJAX but I've completely stuck somewhere.
So I have the following code:
<label>View as:</label> <a href ="#" onClick="return false" onmousedown="javascript:swapContent('con1');">Test 1</a> / <a href ="#" onClick="return false" onmousedown="javascript:swapContent('con2');">Test 2</a><br/>
<div id = "myDiv">asdasd</div>
The following .js script:
function swapContent(cv) {
$("#myDiv").html("Put animated .gif here").show();
var url = templateDir;
$.post(url.concat("/profileajax.php"), {contentVar: cv}, function(data) {
$("#myDiv").html(data).show();
})
}
And the following profileajax.php page:
<?php
$contentVar = $_POST['contentVar'];
if($contentVar == "con1") {
echo get_bloginfo('template_directory');
}
else {
echo "Test";
}
?>
However when I'm clicking on the first link, I get the following error: Fatal error: Call to undefined function get_bloginfo() in D:\Webdesign\XAMPP\htdocs\wordpress\wp-content\themes\globestate\profileajax.php on line 4.
How can I make it work? (By the way I'm using Wordpress)