开发者

Declaring a javascript object literal in Script#

开发者 https://www.devze.com 2023-03-09 22:24 出处:网络
I am trying to replicate a jquery ajax call in Script# and in the data option I am passing an object literal

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 ca开发者_运维知识库me 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消