将参数作为查询字符串从asp.net传递给fancybox的ajax调用
我正在asp.net网页上工作,我正在使用fancy box向您展示tube视频 到目前为止,它工作正常,我还需要对asp.net文件将参数作为查询字符串从asp.net传递给fancybox的ajax调用,asp.net,jquery,asp.net-ajax,fancybox,Asp.net,Jquery,Asp.net Ajax,Fancybox,我正在asp.net网页上工作,我正在使用fancy box向您展示tube视频 到目前为止,它工作正常,我还需要对asp.net文件UpdateVideoViews.aspx?VideoID=xyzxvtmiw进行ajax调用,以便我可以更新数据库中此视频的点击次数/视图(当有人单击缩略图时) 到目前为止,它工作正常,我能够在fancy box中显示视频并同时进行ajax调用,但问题是我无法将youtubeVideoID查询字符串传递到ajax脚本的一部分,以便它获取youtubeVideoI
UpdateVideoViews.aspx?VideoID=xyzxvtmiw
进行ajax调用,以便我可以更新数据库中此视频的点击次数/视图(当有人单击缩略图时)
到目前为止,它工作正常,我能够在fancy box中显示视频并同时进行ajax调用,但问题是我无法将youtubeVideoID
查询字符串传递到ajax脚本的一部分,以便它获取youtubeVideoID以进行正确的视频单击
$.ajax({
type: "POST",
url: "UpdateVideoViews.aspx?youtubeVideoID=7oR4411Pza0",
});
下面是我脚本的一部分
<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' }
});
$.ajax({
type: "POST",
url: "UpdateVideoViews.aspx?youtubeVideoID=7oR4411Pza0",
});
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,//我们将替换此行
“标题”:新标题//
在这方面,我非常感谢您的帮助您是否尝试过使用
数据
设置?(将youtubeVideoID
作为数据传递)检查更多信息