jQuery加载txt文件

时间:2014-10-17 11:59:54

标签: jquery refresh

我使用此脚本刷新div #puu上的数据。如果.load()包含现有的.php文件,一切正常。但是如果我在.load()中使用现有的.txt文件没有任何反应,为什么会这样?

<script>
var refreshId = setInterval(function()
{
     $('#puu').fadeOut("slow").load('152 and 153.txt').fadeIn("slow");
}, 5000);
</script>

2 个答案:

答案 0 :(得分:0)

我认为这是由于该文件名被视为空文件名检查您的文件名      $(&#39;#PUU&#39)。载荷(&#39; 153.txt&#39)。淡入(&#34;慢&#34);

答案 1 :(得分:0)

您应该更改文件名中的空格以使用%20作为空格。此外,您的fadeIn在加载返回数据之前触发。

$('#puu').fadeOut("slow")
         .load('152%20and%20153.txt', function() { 
             $(this).fadeIn("slow"); 
         });