0

i have a returnig list result from controller to View

@model List<CartItemDetailDto>

is it possible to have this result list set to a jquery variable

 <script>
    var modelList =@(Model);
  </script>
0

1 Answer 1

0

Yes you can use that. Just convert in to Json String like below:

var json = @Html.Raw(Json.Encode(@Model));

now you can use your model data in Jquery.

Sign up to request clarification or add additional context in comments.

2 Comments

It will convert model into json object and JSON.srtingify will convert that object into json string. I already used same approach and it's working well for me.
oh Fine will make changes according to your comment.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.