我在我的网页中嵌入了一个提交搜索的按钮。此表单的搜索值txt
由php code
. 我遇到的问题是php code
它仅在网页加载时加载一次。这是一个问题,因为txt
文件在不断变化,并且它的内容在第一次时才被读取。所以我想要的是在单击提交按钮时输入搜索值。换句话说,我正在寻找php code
运行并填充搜索值 onClick。
这是表格:
<form id="search" action="http://www.example.com/search.php" method="get" target="_blank">
<input type="hidden" name="search" value="<?php $file = "http://www.clavederock.com.ar/zararadio/CurrentSong.txt";
$f = fopen($file, "r");
while ( $line = fgets($f, 1000) ) {
$line = preg_replace("/-(.*?)-/", "", $line);
print $line;}?>"/>
<input type="hidden" name="language" value="es"/>
<input type="image" src="img/psue.png">
</form>
任何建议或帮助将不胜感激!!谢谢!
编辑:我看到 php 在页面交付之前被执行,因为它是服务器端脚本。为了解决这个问题,有没有办法让php code
每 x 秒运行一次?就像你在 div 中所做的那样:
setInterval(function(){
$('#ID').load('example.php');
}, 10000);