0
我有一個AJAX獲取新的HTML並替換response.html中的表單數據。替換前我需要更改一個屬性。如何更改AJAX響應HTML,然後在jQuery中繼續替換?
這裏是我的嘗試,但我不能得到正確的事:
success: function(response, status, xhr) {
if (response.data.html !== null) {
var newdata = response.data.html;
if(firstload == 1){
var newhtml = $(newdata).find('.trigger').attr('data-firstload',0);
// now I need to replace newdata
}
$(container).html(newdata);
}
}
我想應答已經是html字符串了。 JQuery適用於DOM元素,而不是HTML字符串。我想,你需要正則表達式或者影子技術來做你想做的事情。 – mondjunge
'$(container).empty()。append($(newdata));' – lshettyl