1
我正在使用花式框顯示您的管狀視頻的asp.net網頁上工作。在顯示視頻時進行ajax調用以更新視頻點擊
到目前爲止它工作正常,我還需要做一個ajax調用asp.net文件updateHits.aspx?VideoID=xyzxvtmiw
,以便我可以更新數據庫中此視頻的點擊次數/視圖(當有人點擊縮略圖時)。我不太清楚在用戶點擊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>
基於上面的代碼,我正在重新初始化花式盒,因爲我有UpdatePanel中的一部分。
但我不知道我應該如何讓阿賈克斯呼籲updateHits.aspx?VideoID=xyzxvtmiw
,以便我可以更新數據庫。
你的意思是像'「的href」:「updateHits.aspx視頻ID = xyzxvtmiw''因爲我不不從AJAX任何結果調用它只會更新... – Learning 2013-03-04 11:45:41
不,我通過一個單獨的$的意思。 ajax()行。查看更新後的答案。如果你想知道更多關於$ .ajax的信息,Google是你的朋友。 ;) – magnattic 2013-03-04 11:53:06
由於某種原因,它不工作,我處於調試模式,並通知調用文件沒有被生成。 – Learning 2013-03-04 12:15:36