1

how to access viewdata value in script using jquery in mvc 4.

I new to mvc ,I am not getting the view data value to javascript. I tried

var data = "@ViewData["notify"]";

1 Answer 1

2

Use this:

var data = @Html.Raw(Json.Encode(ViewData["notify"]));

More:

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

1 Comment

Is there any way to debug this? I'm using jQuery v2.2.1, and it says, Uncaught SyntaxError: Invalid or unexpected token

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.