停止刷新Ajax,JavaScript,PHP [英] Stop refreshing with ajax , javascript , php

查看:107
本文介绍了停止刷新Ajax,JavaScript,PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码如下所示:

My code looks like this:

<html>
<body>

<script language="javascript" type="text/javascript">
function ajaxFunction(){
    var ajaxRequest;  // The variable that makes Ajax possible!
        ajaxRequest = new XMLHttpRequest();
    var age = document.getElementById('age').value;
    var queryString = "?age=" + age;
    ajaxRequest.open("GET", "ajax-example.php" + queryString, true);
    ajaxRequest.send(null); 
}
</script>

<form name='myForm'>
Max Age: <input type='text' id='age' /> <br />
<input type='button' onclick='ajaxFunction()' value='Query MySQL' />
</form>
</body>
</html>

我使用Ajax来停止重定向,但它仍然令人耳目一新,我该如何阻止它?

I used Ajax to stop redirection but it is still refreshing, how can I stop it?

推荐答案

您可以尝试添加return false;

You could try adding return false;

<input type='button' onclick='ajaxFunction();return false' value='Query MySQL' />

这篇关于停止刷新Ajax,JavaScript,PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆