0

I am using jquery ajax. Ajax call is working fine but data inside div is not updating. OnSuccess it gets full page html :(

View (MyDataView.cshtml):

<div id="userGridDiv">
     <a id="lnkName" style="cursor:pointer">Name</a>
    //This div also contain other data....
</div>

@section scripts{
<script type="text/javascript">
    $(document).ready(function () {
      $("#lnkName").click(function () {
            $.ajax({
                url:  '@Url.Action("ShowData", "Controller")',
                type: "POST",
                data: { id: 1, sort: "Name" },
                }
            }).done(function () {

            }).success(function (dv) {
                alert(dv)
            })
            a$.ajaxOptions(
            {
                UpdateTargetId : "userGridDiv",
            })
        });
    });

Contoller Method is:

    public ViewResult ShowSata(int id, string data)
    {
           var model = GetDBData(id, data);
           View("MyDataView")
     }

Please let me know what i am doing wrong.

4

1 回答 1

1

像这样使用:

 public ViewResult ShowSata(int id, string data)
 {
       var model = GetDBData(id, data);
       return PartialView("MyDataView")
 }
于 2013-05-24T11:27:36.777 回答