Javascript AJAX包括不加载的页面
我有一个挑战: 如何使用AJAX在页面上重新加载Javascript AJAX包括不加载的页面,javascript,php,ajax,Javascript,Php,Ajax,我有一个挑战: 如何使用AJAX在页面上重新加载,而不加载条,也不在加载内容时消失 只要加载了新内容,我就想保留以前生成的内容 这是我的脚本,但在循环中加载内容时,它会闪烁: <script type="text/javascript"> function showCargo_34(urlparms) { if (window.XMLHttpRequest) {// co
,而不加载条,也不在加载内容时消失
只要加载了新内容,我就想保留以前生成的内容
这是我的脚本,但在循环中加载内容时,它会闪烁:
<script type="text/javascript">
function showCargo_34(urlparms)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttpshowCargo_34=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttpshowCargo_34=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttpshowCargo_34.onreadystatechange=function()
{
if (xmlhttpshowCargo_34.readyState==4 && xmlhttpshowCargo_34.status==200)
{
document.getElementById("Cargo_34").innerHTML=xmlhttpshowCargo_34.responseText;
}
}
xmlhttpshowCargo_34.open("GET","modules/desktop/desktop/script_cargo.php?"+urlparms,true); // modules/catalogitem/script_categorylist.php?"+urlparms
xmlhttpshowCargo_34.send();
};
</script>
<div id="Cargo_34"></div>
<script>
function repeat_Cargo_34() {
showCargo_34('baseid=1&moduleid=10&gridmoduleid=133&speed=180&x=3&y=4');
setTimeout( repeat_Cargo_34, 20000);
};
repeat_Cargo_34();
</script>
功能展示货物(urlparms)
{
if(window.XMLHttpRequest)
{//IE7+、Firefox、Chrome、Opera、Safari的代码
xmlhttpshowCargo_34=新的XMLHttpRequest();
}
其他的
{//IE6、IE5的代码
xmlhttpshowCargo_34=新的ActiveXObject(“Microsoft.XMLHTTP”);
}
xmlhttpshowCargo_34.onreadystatechange=函数()
{
如果(xmlhttpshowCargo_34.readyState==4&&xmlhttpshowCargo_34.status==200)
{
document.getElementById(“Cargo_34”).innerHTML=xmlhttpshowCargo_34.responseText;
}
}
xmlhttpshowCargo_34.open(“GET”,“modules/desktop/desktop/script_cargo.php?”+urlparms,true);//modules/catalogitem/script_categorylist.php?”+urlparms
xmlhttpshowCargo_34.send();
};
功能重复_Cargo_34(){
showCargo_34('baseid=1&moduleid=10&gridmoduleid=133&speed=180&x=3&y=4');
设置超时(重复34、20000次);
};
重复上述步骤;
我会将jquery用于ajax。它更快、更简单
简单方法
$("#element_id").load("http://url.com");
你可以找到更先进的方法
您还谈到了保留previoius内容。对于innerHTML,只需使用+=即可:
document.getElementById("Cargo_34").innerHTML += xmlhttpshowCargo_34.responseText;
我会使用jquery来实现ajax,它更快、更简单 简单方法
$("#element_id").load("http://url.com");
你可以找到更先进的方法
您还谈到了保留previoius内容。对于innerHTML,只需使用+=即可:
document.getElementById("Cargo_34").innerHTML += xmlhttpshowCargo_34.responseText;
我会使用jquery来实现ajax,它更快、更简单 简单方法
$("#element_id").load("http://url.com");
你可以找到更先进的方法
您还谈到了保留previoius内容。对于innerHTML,只需使用+=即可:
document.getElementById("Cargo_34").innerHTML += xmlhttpshowCargo_34.responseText;
我会使用jquery来实现ajax,它更快、更简单 简单方法
$("#element_id").load("http://url.com");
你可以找到更先进的方法
您还谈到了保留previoius内容。对于innerHTML,只需使用+=即可:
document.getElementById("Cargo_34").innerHTML += xmlhttpshowCargo_34.responseText;
使用jQuery的AJAX更简单。请查看load()函数,例如setInterval。例如:
setInterval(function(){ $('#div').load('file.html'); }, 5000}
每隔5秒钟,它就会加载file.html到
使用jQuery的AJAX,这更简单。查看load()函数,例如setInterval。例如:
setInterval(function(){ $('#div').load('file.html'); }, 5000}
每隔5秒钟,它就会加载file.html到
使用jQuery的AJAX,这更简单。查看load()函数,例如setInterval。例如:
setInterval(function(){ $('#div').load('file.html'); }, 5000}
每隔5秒钟,它就会加载file.html到
使用jQuery的AJAX,这更简单。查看load()函数,例如setInterval。例如:
setInterval(function(){ $('#div').load('file.html'); }, 5000}
每隔5秒钟,它就会将file.html加载到
,如果您不想使用jquery,我建议您使用第二个ajax函数,并将当前函数更改为一个不可见的div,加载和更改完成后,您将在其中回显以下行
//Echo this once all data has been loaded and changed.
//$newurlPalms is what you would have echoed normally but in a urlpalm.
echo "<style onload='showCargo2($newurlpalms)'></style>";
//so make this only load and save all the data and then echo above line in
//a hidden div
function showcargo(urlpalms){ajaxcode}
//make this show the data in the right div.
function showcargo2(urlpalms){ajaxdoce}
//一旦加载并更改了所有数据,就回显此消息。
//$newurlPalms是您在urlpalm中通常会发出的回声。
回声“;
//所以,只加载并保存所有数据,然后在上面的行中回音
//隐藏的div
函数showcargo(urlpalms){ajaxcode}
//使其显示右侧div中的数据。
函数showcargo2(urlpalms){ajaxdoce}
这样,它不会删除数据,加载完成后,echo将导致第二个函数自动运行,从而能够立即显示数据。如果您不想使用jquery,我建议创建第二个ajax函数,并将当前函数更改为一个不可见的div,您可以在其中回显以下内容装载和更换完成后,重新安装管线
//Echo this once all data has been loaded and changed.
//$newurlPalms is what you would have echoed normally but in a urlpalm.
echo "<style onload='showCargo2($newurlpalms)'></style>";
//so make this only load and save all the data and then echo above line in
//a hidden div
function showcargo(urlpalms){ajaxcode}
//make this show the data in the right div.
function showcargo2(urlpalms){ajaxdoce}
//一旦加载并更改了所有数据,就回显此消息。
//$newurlPalms是您在urlpalm中通常会发出的回声。
回声“;
//所以,只加载并保存所有数据,然后在上面的行中回音
//隐藏的div
函数showcargo(urlpalms){ajaxcode}
//使其显示右侧div中的数据。
函数showcargo2(urlpalms){ajaxdoce}
这样,它不会删除数据,加载完成后,echo将导致第二个函数自动运行,从而能够立即显示数据。如果您不想使用jquery,我建议创建第二个ajax函数,并将当前函数更改为一个不可见的div,您可以在其中回显以下内容装载和更换完成后,重新安装管线
//Echo this once all data has been loaded and changed.
//$newurlPalms is what you would have echoed normally but in a urlpalm.
echo "<style onload='showCargo2($newurlpalms)'></style>";
//so make this only load and save all the data and then echo above line in
//a hidden div
function showcargo(urlpalms){ajaxcode}
//make this show the data in the right div.
function showcargo2(urlpalms){ajaxdoce}
//一旦加载并更改了所有数据,就回显此消息。
//$newurlPalms是您在urlpalm中通常会发出的回声。
回声“;
//所以,只加载并保存所有数据,然后在上面的行中回音
//隐藏的div
函数showcargo(urlpalms){ajaxcode}
//使其显示右侧div中的数据。
函数showcargo2(urlpalms){ajaxdoce}
这样,它不会删除数据,加载完成后,echo将导致第二个函数自动运行,从而能够立即显示数据。如果您不想使用jquery,我建议创建第二个ajax函数,并将当前函数更改为一个不可见的div,您可以在其中回显以下内容装载和更换完成后,重新安装管线
//Echo this once all data has been loaded and changed.
//$newurlPalms is what you would have echoed normally but in a urlpalm.
echo "<style onload='showCargo2($newurlpalms)'></style>";
//so make this only load and save all the data and then echo above line in
//a hidden div
function showcargo(urlpalms){ajaxcode}
//make this show the data in the right div.
function showcargo2(urlpalms){ajaxdoce}
//一旦加载并更改了所有数据,就回显此消息。
//$newurlPalms是您在urlpalm中通常会发出的回声。
回声“;
//所以,只加载并保存所有数据,然后在上面的行中回音
//隐藏的div
函数showcargo(urlpalms){ajaxcode}
//妈