using ajax url to call function
- by Steven Vanerp
Hopefully I can ask this correctly cuz I know what I want it to do but can't seem to find any answers from searching.
I have a func.php page where I have all my functions and I want ajax to use one function from that page.
func.php
function toptable()
{
echo"something happens in here";
}
index.php
<?php include 'func.php'; ?>
<script type="text/javascript">
function check_username() {
uname=document.getElementById("username").value;
var params = "user_id="+uname;
var url = "topoftable()";
$.ajax({
type: 'POST',
url: url,
dataType: 'html',
data: params,
beforeSend: function() {
document.getElementById("right").innerHTML= 'checking' ;
},
complete: function() {
},
success: function(html) {
document.getElementById("right").innerHTML= html ;
}
});
}
</script>
Make sense?