【问题标题】:Why doesn't the timestamp parameter get passed along with the request?为什么时间戳参数不随请求一起传递?
【发布时间】:2015-03-04 07:56:08
【问题描述】:

对于一个请求,需要传递四个参数,其中只有三个被传递。参数timestamp 未通过。这可能是什么原因?

$.ajax( {
                    url : 'http://localhost:8081/Football/FeFeed',
                    data : {
                        playernumber : $('#playernumber_goal').val(),
                        timestamp : $('#match').get(0).currrentTime,
                        event : 'goal',
                        team : 'team-name'
                    },
                    type : 'GET'
  })     .done(function(message){

         }).fail(function(message) {

         });

#match 的 HTML:

<video id="match" width="440" controls>
                    <source src="match.mp4" type="video/mp4">
                    <source src="match.ogg" type="video/ogg">
                    Your browser does not support HTML5 video.
</video>

形成的网址是:http://localhost:8081/Football/FeFeed?playernumber=22&amp;event=goal&amp;team=team-name

编辑:我可以传递一个静态变量,例如 100.232

【问题讨论】:

  • 尝试为键时间戳传递静态值,例如“17h15”或您期望的东西
  • @Med.Amine.Touil 我需要发送一个浮点值
  • 也许 $('#match').get(0).currrentTime 会导致问题。所以传递一个静态浮点值。并检查新的构建 URL
  • @Med.Amine.Touil 能够顺利通过。
  • 所以你的问题正如我所料。现在尝试提醒 $('#match').get(0).currrentTime 。你会发现它有问题。你想从这个 jquery 表达式中得到什么?

标签: jquery html ajax floating-point httprequest


【解决方案1】:

currrentTimecurrentTime?!!!

【讨论】:

  • 哇好棒!在你的currrentTime@SuhailGupta 中有 3 个r,规范说它必须只有 2 个。
  • @NK。我想我是关于集中测试:-)
  • @Med.Amine.Touil,显然 ;)
【解决方案2】:

所以如果你想打发视频时间试试这个。

var tempVideo= document.getElementById("match");
var tempTime=tempVideo.currentTime;

在你的 ajax 帖子中

timestamp : tempTime

【讨论】:

  • @Suhail Gupta 希望对您有所帮助
  • $('#match').get(0).currrentTime
  • 我通常使用 $('#match').get(0) 来获取对象 id。所以不知道 $('#match').get(0).currrentTime 是否有效。你有没有试过我的回答。要知道会发生什么,请尝试提醒 $('#match').get(0).currrentTime
  • 为我的东西给出 undefined。
  • @SuhailGupta 试试我的答案。它是纯 JavaScript。如果它有效,那就是 juqery 版本或浏览器类型的问题
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-03-27
  • 2015-09-09
  • 1970-01-01
  • 2017-10-31
  • 2018-08-29
相关资源
最近更新 更多