Declaring a javascript object literal in Script #

I am trying to replicate a jquery ajax call in Script # and pass an object literal in the data parameter

{ id: target.data("id"), name: newName}

I am trying to reproduce this in Script #, but I have not been successful at this time. The first thing that came to mind was an anonymous object:

new { id = target.GetDataValue("id"), name = newName }

but this does not seem to work.

Any ideas?

+3
source share
1 answer

Try

new Dictionary("id", target.GetDataValue("id"), "name", newName)

or

Script.Literal("{ id: target.data(\"id\"), name: newName}")

Both should translate your source code more or less.

+4
source

All Articles