0
我有一个PHP页面,用于显示从数据库中获取的Div值。这个div使用Ajax自动加载数据。我的问题是,当Div重新加载时,我不能在Div中使用Jquery函数或属性中的超额对象(就像在按钮中转换标签一样)。在装有ajax的div上使用jquery
这是使用代码I'm: // jQuery的
$(function() {
$("label").button();
});
// AJAX
var RequestObject = false;
var unidad = <?php echo json_encode($unidad);?>;
parametros='?unidad='+ unidad;
var Archivo = 'obtiene_ultimas_lecturas.php'+ parametros ;
window.setInterval("actualizacion_reloj()", 15000);
if (window.XMLHttpRequest)
RequestObject = new XMLHttpRequest();
if (window.ActiveXObject)
RequestObject = new ActiveXObject("Microsoft.XMLHTTP");
function ReqChange() {
if (RequestObject.readyState==4) {
if (RequestObject.responseText.indexOf('invalid') == -1)
{
document.getElementById("marco").innerHTML = RequestObject.responseText;
}
else
{
document.getElementById("marco").innerHTML = "Error llamando";
}
}
}
function llamadaAjax() {
RequestObject.open("GET", Archivo , true);
RequestObject.onreadystatechange = ReqChange;
RequestObject.send(null);
}
function actualizacion_reloj() {
llamadaAjax();
}
// HTML
<div id="marco" name="marco">
<table>
<tr class="Estilo4">
<td align="center"><input name="nge" type="text" size="9" value="<?php printf("%.3f",$nge); ?>" /> <label>m³</label></td>
</tr>
</table>
</div>
这基本上是我的代码,我想要包含在div中的标签可以获得'按钮'属性。
调用'$( “标签”)。按钮()'阿贾克斯完成 –
@ user1082159我建议你使用[$阿贾克斯(HTTP后://api.jquery.com/jQuery.ajax/)用于ajax功能 – DON
您可以使用'jquery'的'replaceWith'函数http://api.jquery.com/replaceWith/。同样在'ReqChange'中调用该函数。 –