我有一个javascript函数,我想在我的服务器上重定向到php获取结果,然后如果该php文件返回true来完成该函数。我试过这个:在php中返回true,并在javascript中获取结果
if (window.location.href = "http://cosy.azurewebsites.net/servertest.php?u=" + Username + "&p=" + Password ==true)
{
alert ("it was true");
}
但是,只是返回false,不管我做什么。
当我到这里的PHP页面是我返回null并返回给javascript:
header("location:javascript://history.go(-1)?result=true/false");
return true;
//header('Location:some_page.php?result=true/false');
exit;
我知道这是不是这样做的正确的方式,但我尝试了一些不同的事情这是我得到的!
我想你需要的是[jQuery ajax调用](http://api.jquery.com/jquery.ajax/)。 –
我不明白你需要什么,你可以编辑这个问题来澄清。也许@AuditeMarlow可以做到这一点。 – Hisham
使ajax调用http://cosy.azurewebsites.net/servertest.php?u=“+用户名+”和p =“+密码,并发送来自服务器的真或假响应 –