Jquery ASP.NET MVC中的动态图像和Ajax

Jquery ASP.NET MVC中的动态图像和Ajax,jquery,asp.net-mvc,ajax,colorbox,Jquery,Asp.net Mvc,Ajax,Colorbox,我正在尝试使用ajax和colorbox显示一个详细的partialview。它工作得很好,但只是第一次。在此之后,GetGraph将不运行,并再次显示第一个图像。如果我重新加载整个页面,它会再次工作一次。详细信息正在更新,正常,只是图表图像不起作用 以下是我目前掌握的情况: jQuery: <script type="text/javascript"> $(document).ready(function () { $("a.details").click(function

我正在尝试使用ajax和colorbox显示一个详细的partialview。它工作得很好,但只是第一次。在此之后,GetGraph将不运行,并再次显示第一个图像。如果我重新加载整个页面,它会再次工作一次。详细信息正在更新,正常,只是图表图像不起作用

以下是我目前掌握的情况: jQuery:

<script type="text/javascript">
$(document).ready(function () {
    $("a.details").click(function () {
        var id = $(this).attr("href");
        $.post('GetDetails', { id: id }, function (data) {
            $.fn.colorbox({ open: true, html: data });
        });
        return false;
    });
})
</script>
局部视图:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<SaleDetail>"%>
<table>
<!--Code for displaying detailinfo-->
</table>
<div id="DetailsGraph">
<h3>
    <%=Html.Encode(ResStrings.StatsticStrings.Statistic) %></h3>
    <img src="GetChart" width="700" height="300" alt="Graph" />
</div>

首先,您在$.post中调用GetDetails操作,而不是GetChart操作。

对不起,可能我的帖子不清楚。GetDetails获取detailsdata时,直接从标记中的部分视图调用GetChart。
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<SaleDetail>"%>
<table>
<!--Code for displaying detailinfo-->
</table>
<div id="DetailsGraph">
<h3>
    <%=Html.Encode(ResStrings.StatsticStrings.Statistic) %></h3>
    <img src="GetChart" width="700" height="300" alt="Graph" />
</div>