Javascript 按间隔重新加载输入文本
嗨,我遇到了一个div问题,我用PHP和ajax每隔15秒重新加载一次。它工作正常,但我想知道的唯一一件事是,是否有可能加载输入文本,当间隔刷新div时,不刷新输入文本,因为有时在输入中写入时,它只是重新加载,并且必须再次写入 以下是部分代码: 文件1,其中我通过ajax将内容加载到div中:Javascript 按间隔重新加载输入文本,javascript,php,jquery,html,ajax,Javascript,Php,Jquery,Html,Ajax,嗨,我遇到了一个div问题,我用PHP和ajax每隔15秒重新加载一次。它工作正常,但我想知道的唯一一件事是,是否有可能加载输入文本,当间隔刷新div时,不刷新输入文本,因为有时在输入中写入时,它只是重新加载,并且必须再次写入 以下是部分代码: 文件1,其中我通过ajax将内容加载到div中: <script type="text/javascript">// <![CDATA[ $(document).ready(function() { $.ajaxSetup({ cach
<script type="text/javascript">// <![CDATA[
$(document).ready(function() {
$.ajaxSetup({ cache: false }); // This part addresses an IE bug. without it, IE will only load the first number and will never refresh
setInterval(function() {
$('#precio').load('valoractual.php');
}, 15000); // the "3000" here refers to the time to refresh the div. it is in milliseconds.
});
// ]]></script>
//
以下是重新加载的表单:
<p>Current Bid: <?php echo "USD ".$puja; ?></p>
<p><form id="bid" name="bid">
<input type="text" name="puja" placeholder="<?php $sobrepujar = $puja + 500; echo $sobrepujar; ?>" id="puja" size="14" /><input type="hidden" id="usuario" value="<?php echo $_SESSION['idusuario']; ?>" /><input type="hidden" id="valoractual" value="<?php echo $puja; ?>" /><input type="hidden" id="idpuja" value="<?php echo $idpuja; ?>" /> <input type="button" id="submit" value="B I D"/>
</form>
当前出价:
(重新)仅当页面上没有#puja元素时加载页面,或者(它没有焦点和空值):
//
它不会加载文件,因为“puja”在要加载的文件中,而脚本在主文件中
<script type="text/javascript">// <![CDATA[
$(document).ready(function() {
$.ajaxSetup({ cache: false }); // This part addresses an IE bug. without it, IE will only load the first number and will never refresh
setInterval(function() {
if($("#puja").length == 0 || (!$("#puja").is(":focus") && $("#puja").val() == "")) {
$('#precio').load('valoractual.php');
}
}, 15000); // the "3000" here refers to the time to refresh the div. it is in milliseconds.
});
// ]]></script>