简体   繁体   English

同一会话中有多个AJAX POST请求

[英]Multiple AJAX POST requests in same session

I am trying to finish my video view count functionality. 我正在尝试完成我的视频观看次数功能。 I am sending an AJAX post request to create a video view after the video has finished playing. 视频播放完毕后,我正在发送AJAX发布请求以创建视频视图。 I have a video playlist container that loads new videos via jquery. 我有一个视频播放列表容器,可通过jquery加载新视频。 When I load the page, my AJAX POST call works for the first video in the playlist however, when I click on another video the AJAX request is not recognized. 加载页面时,我的AJAX POST调用适用于播放列表中的第一个视频,但是,当我单击另一个视频时,无法识别AJAX请求。

This is the code I am calling to create the view. 这是我用来创建视图的代码。 The "$('#video1').data('videoId'" loads the video's ID. “ $('#video1')。data('videoId'”加载视频的ID。

jwplayer().onComplete(function(event) {
    $.ajax({
        type: 'POST',
        url: '<%= create_media_view_path %>',
        cache: false,
        data: { m: $('#video1').data('videoId') }


    });

Is there anything special I need to do to make multiple post requests? 发出多个帖子请求,我需要做些特别的事情吗? Do I need to reload this function each time a new video is selected? 每次选择新视频时,我是否需要重新加载此功能?

Thanks in advance. 提前致谢。

I ended up finding the fix... All I needed to do was load the onComplete function again for every video. 我最终找到了解决方法……我要做的就是为每个视频再次加载onComplete函数。 I simply copied and pasted it into my jquery video container to be reloaded everytime a video is clicked. 我只是将其复制并粘贴到我的jquery视频容器中,以便在每次单击视频时重新加载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM