using ajax url to call function
Posted
by
Steven Vanerp
on Stack Overflow
See other posts from Stack Overflow
or by Steven Vanerp
Published on 2013-11-08T21:50:39Z
Indexed on
2013/11/08
21:52 UTC
Read the original article
Hit count: 147
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?
© Stack Overflow or respective owner