在我的php中我有这个:
<?php
@include_once('fields.php');
$gg = fetchinfo("val","inf","n","current");
$mm = fetchinfo("val","info","n","max");
$cc = fetchinfo("num","games","id",$gg);
$percent = $cc / $mm *100;
echo'<input class="knob" id="progress-circle" data-fgcolor="#f15700" data-bgcolor="rgba(23,28,34,0.8)" data-min="'.$cc.'" data-max="'.$mm.'" data-thickness=".2" readonly="readonly" value="'.$cc.'" data-width="18%" style="width: 142px; height: 92px; position: absolute; vertical-align: middle; margin-top: 92px; margin-left: -209px; border: 0px; font-style: normal; font-variant: normal; font-weight: bold; font-stretch: normal; font-size: 69px; line-height: normal; font-family: Arial; text-align: center; color: rgb(241, 87, 0); padding: 0px; -webkit-appearance: none; background: none;">';
?>
我有一个js文件,我想刷新,并在使用此代码更改时更改清单:
refresh();
function refresh()
{
$.ajax({
type: "GET",
url: "pro.php",
error: function(err) {
console.log(err);
},
success: function(result) {
$("#progress-circle").val(result).trigger('change');
}
});
setTimeout(refresh, 1000);
}
但是当价值发生变化时,它不会改变我的html,它只会在刷新页面时更新。
答案 0 :(得分:0)
使用jQuery&#39; val()
时,您应该只更新value属性。如果你提供整个html节点,它就无法工作。
您可以更新在$percent = ...
和echo
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
// Kein AJAX-Request, der passende Header fehlt
echo $percent;
exit;
}