简体   繁体   中英

How to read a c# server side value in jquery

I've a JArray response value like below

{[
  {
    "id": "90b254dc-3fcd-4e7c-9943-59bce366ccdc",
    "invoice_number": "510002500007368" 
  }
]}

i'm getting this value from c# class ..when I try to read in jQuery like below ways

  var tmp = '@Model.Transactions';
    var tmp = Model.Transactions;
    var tmp = @Model.Transactions;

from that I'm getting the values like below image ... i need a structured values. let me know if any idea.. thanks

响应值图像

You need to render it in a "raw" manner like this, without escaping or encoding so it will remaing "correct" JSON:

var tmp = @:Model.Transactions;

You can also for example prepare your JSON string in the controller eg Model.MyJson then use @:Model.MyJson in the view (notice : after @ ).

This is shortcut for @Html.Raw(myJson);

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