喜誰能幫我這個概率,刷新另一個URL通過點擊按鈕
設M與員工/ refresh1.php中,我有一個按鈕如下
當我點擊這個提交工作按鈕的員工/ refresh2.php有刷新
在refresh2.php我已經followinf FUNC
echo(rand(10,100));
這樣的onclick的提交按鈕新的R必須生成數字。我已經看到了幾個功能,但它有助於刷新相同的頁面,但我的問題是我刷新另一頁上的提交按鈕,這是在不同的頁面。
喜誰能幫我這個概率,刷新另一個URL通過點擊按鈕
設M與員工/ refresh1.php中,我有一個按鈕如下
當我點擊這個提交工作按鈕的員工/ refresh2.php有刷新
在refresh2.php我已經followinf FUNC
echo(rand(10,100));
這樣的onclick的提交按鈕新的R必須生成數字。我已經看到了幾個功能,但它有助於刷新相同的頁面,但我的問題是我刷新另一頁上的提交按鈕,這是在不同的頁面。
您必須在打開時給新窗口命名,然後調用onClick事件[新窗口的名稱] .location.href = href; href將是您想要刷新的新頁面的網址。
這將刷新div並在refreshDIV
中打印的refresh2.php
。
<script type="text/javascript">
$(document).ready(function(){
$("#refreshDIV").click(function(){
$("#refreshDIV").load('refresh2.php');
});
});
</script>
<div id="refreshDIV">
Click here to load
</div>
你是什麼刷新員工/ refresh2.php頁的意思???這是否意味着每次單擊該按鈕時,都會將重定向到該頁面,並顯示您想要的輸出...或者,當前頁面每次都從employee/refresh2.php頁面獲取新的隨機值並在employee/refresh1.php頁面上顯示給你?
如果是後者的話,那麼你需要學習AJAX的基礎知識...
想這是你的員工/ refresh.html頁面編碼
<body>
<input type="submit" onclick="dothis()">
<script>
function dothis()
{
if(windows.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
elseif(windows.ActiveXObject)
{
xmlhttp=new ActiveXObject();
}
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState==4)
{
document.getElementById("demo").innerHTML=xmlhttp.responseText;
}
}
$url="employee/refresh2.php?q";
xmlhttp.open("Get",$url,true);
xmlhttp.send(null);
}
</script>
<div id="demo"></div>
</body>
and then on employee/refresh2.php page do this<br>
<?php if(isset['q'])
echo (rand(10,100));
?>
您的代碼將剛上顯示一個隨機數屏幕。它與頁面刷新有什麼關係? –
你正在使用父窗口? –
它必須每次生成新的隨機數 – namratha