Home > Mobile >  How to read a c# server side value in jquery
How to read a c# server side value in jquery

Time:07-21

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

Response Value Image

CodePudding user response:

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 e.g. Model.MyJson then use @:Model.MyJson in the view (notice : after @).

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

  • Related