Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript-jQuery通过带有时间中断的增量XML数据进行循环_Javascript_Jquery_Xml_Loops - Fatal编程技术网

Javascript-jQuery通过带有时间中断的增量XML数据进行循环

Javascript-jQuery通过带有时间中断的增量XML数据进行循环,javascript,jquery,xml,loops,Javascript,Jquery,Xml,Loops,好的,从我是一名PHP开发人员开始,我知道一些Javascript-jQuery的复杂特性。但是编程只是语法问题,对吗( 我有一件非常困难的事情要做(对我来说),我的大脑正在崩溃 按照逻辑,这就是我必须做的: 循环遍历一个XML文件,从每个文件中获取数据,并通过传递从XML中获取的参数来编写一个DIV,停留3秒钟,然后转到下一个XML数据。 如果找不到数据,请在您所在的位置等待,并在找到新数据后继续(当您的数据可用时,XML文件将递增..这是由我的外部引擎完成的) 现在我已经创建了创建div和获

好的,从我是一名PHP开发人员开始,我知道一些Javascript-jQuery的复杂特性。但是编程只是语法问题,对吗( 我有一件非常困难的事情要做(对我来说),我的大脑正在崩溃

按照逻辑,这就是我必须做的:

循环遍历一个XML文件,从每个文件中获取数据,并通过传递从XML中获取的参数来编写一个DIV,停留3秒钟,然后转到下一个XML数据。 如果找不到数据,请在您所在的位置等待,并在找到新数据后继续(当您的数据可用时,XML文件将递增..这是由我的外部引擎完成的)

现在我已经创建了创建div和获取参数的函数(如下所示),但是如何循环XML数据(如下所示)并等待3秒钟,然后转到下一个数据

这只是一个起点…一个对我来说足够好的方向

我尝试了所有可能的stackoverflow解决方案,但我只得到了错误,所以如果我没有显示任何尝试,那么很抱歉……这完全是无用的

挑战开放!如果您愿意尝试,请提前感谢:)

这是通过获取参数来创建DIV的函数:

function makeCvdBubbleAnimator(params)
    {  
    var cvdIndexId = params.cvdIndexId;
    var cvdTweetAuthor = params.cvdTweetAuthor;
    var cvdTweetDescription = params.cvdTweetDescription;

    objectreference = document.createElement('div');
    objectreference.setAttribute('id', 'indexId-'+cvdIndexId.toString());


    $(objectreference).html('\
    <div class="cvd_left_master_item">\
           <div class="cvd_left_tweet_margin_float">\
                        <img class="cvd_animator" src="cross_video_day/images/cvd_animator.png" /><span class="cvd_left_tweet_animator">@Animator</span>\
                        <span class="cvd_left_tweet_text">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras ut posuere justo, eget consequat tortor. In sollicitudin condimentum arcu sed.</span>\
                    </div>\
                    <div class="clear_both"></div>\
                    <span class="cvd_left_blue_arrow"></span>\
                </div>\
');

    if (cvdTweetAuthor) $(objectreference).find('.cvd_left_tweet_animator').html(cvdTweetAuthor);
    if (cvdTweetDescription) $(objectreference).find('.cvd_left_tweet_text').html(cvdTweetDescription);

    return (objectreference) //objectreference is the reference of the just created tweet
    }
函数makeCvdBubbleAnimator(参数)
{  
var cvdIndexId=params.cvdIndexId;
var CVDTweetuthor=参数CVDTweetuthor;
var cvdTweetDescription=参数cvdTweetDescription;
objectreference=document.createElement('div');
objectreference.setAttribute('id','indexId-'+cvdIndexId.toString());
$(objectreference).html('\
\
\
@动画师\
在索利西图因调味品中使用的“知识产权”是一种对精英的尊崇\
\
\
\
\
');
if(cvdtweetathor)$(objectreference).find('.cvd_left_tweet_animator').html(cvdtweetathor);
if(cvdTweetDescription)$(objectreference).find('.cvd_left_tweet_text').html(cvdTweetDescription);
return(objectreference)//objectreference是刚刚创建的tweet的引用
}
这是一个XML示例,我必须从中获取参数,并为每个XML条目创建DIV,等待3秒钟,然后转到下一个,如果没有新数据,则停止,当有新数据可用时,继续从以前的位置继续

<?xml version="1.0" encoding="UTF-8"?>
<root bubbles="6">
    <tweet broadcasted="bubble">
        <author><![CDATA[@Liciiious]]></author>
        <description><![CDATA[#EveryoneLovesBeinsport (cc @beinsport @charlesbietry). #pureLIVE]]></description>
        <index>1</index>
    </tweet>
    <tweet broadcasted="bubble">
        <description><![CDATA[Message]]></description>
        <author><![CDATA[beIN Sport]]></author>
        <index>2</index>
    </tweet>
        <tweet broadcasted="bubble">
        <author><![CDATA[@Liciiious]]></author>
        <description><![CDATA[#EveryoneLovesBeinsport (cc @beinsport @charlesbietry). #pureLIVE]]></description>
        <index>3</index>
    </tweet>
    <tweet broadcasted="bubble">
        <description><![CDATA[Message]]></description>
        <author><![CDATA[beIN Sport]]></author>
        <index>4</index>
    </tweet>
        <tweet broadcasted="bubble">
        <author><![CDATA[@MAuricious]]></author>
        <description><![CDATA[#EveryoneLovesBeinsport (cc @beinsport @charlesbietry). #pureLIVE]]></description>
        <index>5</index>
    </tweet>
    <tweet broadcasted="bubble">
        <description><![CDATA[Message]]></description>
        <author><![CDATA[beIN Sport]]></author>
        <index>6</index>
    </tweet>
</root>

1.
2.
3.
4.
5.
6.

您似乎需要setInterval()或setTimeout()之类的东西,它们将在指定的时间后执行处理程序。要获取xml,可以使用Ajax技术。一些jquery的基础知识可能就可以了。你说的“等待你在哪里,什么时候发现新数据”是什么意思?JavaScript永远不应该“等待”,它不应该用于流解析(尽管如果您确实需要流解析,请查看WebSocket,这样您的JS就可以获得开始做某事的信号)。至于“3秒钟内什么都不做”部分:
函数dostuff(){processData(readData(datasource));setTimeout(dostuff,3000);}
,但这个问题听起来仍然非常“JavaScript不是这样工作的”,并解释了为什么需要这样做,以便我们可以对其进行评论,这可能会更好地为您服务。