Asp.net 显示视频时进行ajax调用以更新视频点击
我正在asp.net网页上工作,我正在使用fancy box向您展示tube视频 到目前为止,它工作正常,我还需要对asp.net文件Asp.net 显示视频时进行ajax调用以更新视频点击,asp.net,jquery,fancybox,Asp.net,Jquery,Fancybox,我正在asp.net网页上工作,我正在使用fancy box向您展示tube视频 到目前为止,它工作正常,我还需要对asp.net文件updateHits.aspx?VideoID=xyzxvtmiw进行ajax调用,以便更新数据库中此视频的点击/视图(当有人单击缩略图时)。我不太清楚当用户在video.aspx页面上单击视频的图像缩略图时如何拨打此电话 下面是我脚本的一部分 <script type="text/javascript"> //Code to Reinitia
updateHits.aspx?VideoID=xyzxvtmiw
进行ajax调用,以便更新数据库中此视频的点击/视图(当有人单击缩略图时)。我不太清楚当用户在video.aspx页面上单击视频的图像缩略图时如何拨打此电话
下面是我脚本的一部分
<script type="text/javascript">
//Code to Reinitialize Fancybox script when using update panel START
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_initializeRequest(InitializeRequest);
prm.add_endRequest(EndRequest);
function InitializeRequest(sender, args) { }
function EndRequest(sender, args) { InitMyFancyBox(); }
$(document).ready(function () {
InitMyFancyBox();
});
function InitMyFancyBox() {
$(document).ready(function () {
$(".youtube").click(function () {
// first, get the value from the alt attribute
var newTitle = $(this).find("img").attr("alt"); // Get alt from image
$.fancybox({
'padding': 0,
'autoScale': false,
'transitionIn': 'none',
'transitionOut': 'none',
//'title': this.title, // we will replace this line
'title': newTitle, //<--- this will do the trick
'width': 680,
'height': 495,
'href': this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
'type': 'swf',
'swf': { 'wmode': 'transparent', 'allowfullscreen': 'true' }
});
return false;
});
});
}
</script>
<asp:Repeater ID="rptvideos" runat="server" >
<ItemTemplate>
<div class="single-video-wrapper">
<asp:HyperLink ID="hylnkvideo" CssClass="youtube" NavigateUrl='<%# getVideoURL(Eval("VideoID"), Eval("VideoYoutubeID")) %>' runat="server">
<div class="video-image-wrapper">
<asp:Image ID="imgvideo" ImageUrl='<%# getVideoImagePath(Eval("VideoYoutubeID"), Eval("VideoYoutubeIcon")) %>' AlternateText='<%# getVideoTitleDesc(Eval("VideoDate"),Eval("VideoTitle"),Eval("VideoDesc")) %>' runat="server" CssClass="video-thumbnail" />
</div>
<div class="video-name">
<asp:Label ID="lblvideoName" CssClass="video-name-lbl" runat="server" Text='<%#Eval("VideoTitle") %>'></asp:Label>
</div>
<div class="video-issue">
<asp:Label ID="lblVideoIssue" CssClass="video-issue-lbl" runat="server" Text='<%#getIssuCode(Eval("IssueCode")) %>'></asp:Label>
</div>
</asp:HyperLink>
</div>
</ItemTemplate>
</asp:Repeater>
//使用“更新”面板“开始”时重新初始化Fancybox脚本的代码
var prm=Sys.WebForms.PageRequestManager.getInstance();
prm.添加_initializeRequest(initializeRequest);
prm.add_endRequest(endRequest);
函数初始化请求(发送方,参数){}
函数EndRequest(发送方,参数){InitMyFancyBox();}
$(文档).ready(函数(){
InitMyFancyBox();
});
函数InitMyFancyBox(){
$(文档).ready(函数(){
$(“.youtube”)。单击(函数(){
//首先,从alt属性中获取值
var newTitle=$(this.find(“img”).attr(“alt”);//从图像中获取alt
$.fancybox({
“填充”:0,
“自动缩放”:false,
“transitionIn”:“无”,
“transitionOut”:“无”,
//'title':this.title,//我们将替换此行
“标题”:新标题//
基于上面的代码,我正在重新初始化fancy box,因为我有updatePanel
但我不确定如何对updateHits.aspx?VideoID=xyzxvtmiw进行ajax调用,以便更新数据库。您可以将ajax调用添加到单击事件:
function InitMyFancyBox() {
$(document).ready(function () {
$(".youtube").click(function () {
// first, get the value from the alt attribute
var newTitle = $(this).find("img").attr("alt"); // Get alt from image
$.fancybox({
//...
});
// your Ajax call here
$.ajax({
type: "POST",
url: "updateHits.aspx?VideoID=xyzxvtmiw"
});
return false;
});
});
}
如果希望ajax调用与fancybox init分开,只需在页面的其他位置添加另一个单击处理程序:
$(".youtube").click(function () {
// your Ajax call here
$.ajax({
type: "POST",
url: "updateHits.aspx?VideoID=xyzxvtmiw"
});
}
你的意思是像
'href':'updateHits.aspx?VideoID=xyzxvtmiw'
因为我不知道ajax调用的任何结果,它只会更新…不,我的意思是通过单独的$.ajax()行。查看更新的答案。如果你想了解更多关于$.ajax的信息,谷歌是你的朋友。;)由于某些原因,它不工作,我处于调试模式&注意没有调用文件。@attice谢谢它工作,我只是调用了另一个文件。它正在按要求工作。。。