我想要一个简单的按钮,当我点击,它显示了一个文件中的内容为file.php
(当它触发该文件显示了一个随机数),如果它点击数次刷新从内容为file.php
。
I want a simple button that when I click, it shows the content from a file file.php
( this file when triggered it shows a random number) and if it's clicked several times refreshes the content from file.php
.
您可以尝试这样的:
PHP文件:为file.php
PHP File: file.php
<?php
//your php code for random number...
?>
HTML文件:
<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
</head>
<body>
<input type="button" id="clkMe" value="Load File" />
<div id="response"></div>
<script>
$(document).ready(function(){
$("#clkMe").click(function(){
var dataString={};
$.ajax({
url:"file.php",
type: 'POST',
cache:false,
data: dataString,
beforeSend: function() {},
timeout:10000,
error: function() { },
success: function(response) {
$("#response").html(response);
alert(response);
}
});
});
});
</script>
</body>
</html>
我希望这是你所问。
I hope this is what you are asking.
编码快乐!
上一篇:REST风格的前preSS猫鼬和放大器;主干 - 主干model.remove()不工作主干、放大器、风格、工作
下一篇:Autocompleting从JSON数据的文本框在一个PHP文件文本框、文件、数据、Autocompleting