简体   繁体   中英

Declaring a javascript object literal in Script#

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

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

I am trying to reproduce this in Script#, but I am currently unsuccessful. The first thing that came to mind was an anonymous object:

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

but that didn't seem to work.

Any ideas?

Try

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

or

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

Both should translate to your original code more or less.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM