根据不刷新的变量包含不同的PHP


include different php depending on a variable without refresh

经过几个小时的尝试和阅读,我确实需要帮助。

我的主页包含一个PHP文件,它启动了一个我无法更改的进程。

我需要一个按钮,在点击时,改变包含的PHP文件和刷新div与新的包含。

这是一种简单的方法吗?

<input name="Au chateau" type="submit" value="chateau">
<input name="Au relais" type="submit" value="relais">
if ( $Au chateau = "chateau") { include 'test.php' };
else {include 'test.php'};

谢谢大家,谢谢单打,抱歉我的英语不好。我想我是在很好的方式感谢你,加载函数jquery似乎是伟大的。实际上我的代码是:

<script>
$(document).ready(function(){
$("button").click(function(){
$("#div1").load("test.php",function(responseTxt, statusTxt, xhr){
if(statusTxt == "success")
alert("External content loaded successfully!");
if(statusTxt == "error")
alert("Error: " + xhr.status + ": " + xhr.statusText);
});
});
});
</script>

让jQuery AJAX改变这个文本

获取外部内容

还不错,但是我的PHP文件没有找到。我想我的url是错误的,或者可能是PHP无法读取。任何想法?

PHP在服务器端执行,服务器将最终页面传输给客户端。如果不刷新页面,则不能更改内容。

如果你想在不刷新的情况下改变客户端的内容,你可以使用Javascript。