learning
learning

Reputation: 11725

Reading and store ViewBag

I have the following in my controller:

            ViewBag.ProjectID = ID;

How can retrive the projectID in the following in javascript?

$.ajax({
        type: "GET",
        contentType: "application/json; charset=utf-8",
        url: "@Url.Action("Delete")",
        data:
        {
            ***projectID : $("#ProjectID").val()*** 

        },

Upvotes: 0

Views: 1564

Answers (2)

Gautam Jain
Gautam Jain

Reputation: 6849

Following should work

"projectID" : "@ViewBag.ProjectID"

Upvotes: 1

Sergi Papaseit
Sergi Papaseit

Reputation: 16184

data: { 'projectID' : '@ViewBag.ProjectID' } 

Should do the trick.

Upvotes: 0

Related Questions