即时通讯使用一个计时器来调用一个Ajax功能,在从一个单独的PHP页面响应负载。我希望把它因此,内容淡出然后淡入与响应以往任何时候都频繁。
下面是我的code - 我可以抓取的内容,使之在与亏损仅更改衰落部Im。
<脚本类型=文/ JavaScript的>
window.setTimeout('runMore code()',100);
$(文件)。就绪(函数(){
$('#refreshRecords')淡入(2000)。
});
功能runMore code()
{
如果(window.XMLHtt prequest)
{// $ C $下IE7 +,火狐,Chrome,歌剧,Safari浏览器
XMLHTTP =新XMLHtt prequest();
}
其他
{// code对IE6,IE5
XMLHTTP =新的ActiveXObject(Microsoft.XMLHTTP);
}
xmlhttp.onreadystatechange =功能()
{
如果(xmlhttp.readyState == 4和&安培; xmlhttp.status == 200)
{
的document.getElementById(refreshRecords)的innerHTML = xmlhttp.responseText。
$('#refreshRecords)淡入(慢)。
}
}
xmlhttp.open(GET,NewRecords.php,真正的);
xmlhttp.send();
的setTimeout(runMore code(),6000);
}
< / SCRIPT>
我试图用.fadeIn但没有运气做到这一点。我已经挂在了最新的jQuery文件中。
感谢
GCooper
解决方案 $。获得({
网址:NewRecords.php
功能(数据){
//在效果添加淡入
。$('#结果)隐藏()HTML(数据).fadeIn(慢);
}
});
Im using a timer to call an ajax function that loads in a response from a seperate php page. I want to make it so the content fades out then fades in with the response ever so often.
Here's my code - i can grab the content and make it change just the fading in part im at a loss with.
<script type="text/javascript">
window.setTimeout('runMoreCode()',100);
$(document).ready(function(){
$('#refreshRecords').fadeIn(2000);
});
function runMoreCode()
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("refreshRecords").innerHTML=xmlhttp.responseText;
$('#refreshRecords').fadeIn('slow');
}
}
xmlhttp.open("GET","NewRecords.php",true);
xmlhttp.send();
setTimeout("runMoreCode()",6000);
}
</script>
I have tried to do it with .fadeIn but with no luck. I have linked in the latest jQuery file as well.
Thanks
GCooper
解决方案 $.get({
URL: "NewRecords.php",
function(data){
//add fade in effects
$('#result').hide().HTML(data).fadeIn('slow');
}
});