我在编写网站是使用ajax异步调用php文件,这样很麻烦,我想如歌ajax能调用PHP类库中的函数就最好了。我的ajax代码如下:
function useridexist()
{
var userid=document.login.userid.value;
xhr.open("GET","class/useridexist.php?id="+userid,true);
xhr.onreadystatechange=showidexist;
xhr.send(null);
}
function showidexist()
{
if(xhr.readyState == 1)
{
document.getElementById('useridexist').innerHTML="Check the ID, Please wait...";
}
if(xhr.readyState == 4)
{
if(xhr.status == 200)
{
var result=xhr.responseText;
document.getElementById('useridexist').innerHTML=result;
}
}
}
我不想每次都是class/useridexist.php?id="+userid,true);而是最好可以到PHP的类库中调用函数。非常感谢你的回答!!
一楼的方法我想过,但是这样还是需要写很多的页面的,我需要的办法是在一个页面中的PHP类库中的不同函数来解决这些问题,谢谢!!
桃花长相依
犯罪嫌疑人X
肥皂起泡泡
忽然笑
随时随地看视频慕课网APP