gpt4 book ai didi

php - Ajax 多个 div

转载 作者:行者123 更新时间:2023-12-01 06:03:12 24 4
gpt4 key购买 nike

我有这个ajax代码,它在1个div中显示更多细节..我的问题是如何在两个或三个div中显示ajax?

    function GetDetails(id)
{
$(document).ready(one);
function one()
{
if(window.XMLHttpRequest){

xmlhttp = new XMLHttpRequest();
}else {
xmlhttp = new ActiveXObject('Micrososft.XMLHTTP');
}

xmlhttp.onreadystatechange = function() {
if(xmlhttp.readyState ==4 && xmlhttp.status == 200) {
document.getElementById('tv'+id).innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open('GET', 'ajax.php?c='+id, true);
xmlhttp.send();
var thebutton = '#button'+id;
$(thebutton).hide();
}
}

最佳答案

如果您的输出中肯定不会出现某些内容,请在 PHP 代码中分离您想要分离的内容,然后在 JS 中使用 xmlhttp.responseText.split 或 PHPJS。 org 的 [explode()][1] ,如果没有这样的东西,那么您也许应该确保会有。不知何故,例如,在 PHP 中使用 str_replace()

或者,如果您有足够的带宽,请发送多个请求。

关于php - Ajax 多个 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9148223/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com