asp.net mvc - MVC Controller return Content instead of JSON -


i've been working on project of requirements involved json. have need return results model can used in input elements value field. can't use solution have been objects returned instead of plain text value. controller pattern have been using:

public virtual jsonresult foodata() {     var fooresults = new fooqueries().foototal();     return new jsonresult          { jsonrequestbehavior = jsonrequestbehavior.allowget, data = fooresults }; } 

is there way use return content instead of jsonresult? i'm new .net mvc framework , having difficulty finding correct way this.

my current results formatted this:

[{ "foo", 3 }] 

instead prefer plain text can use ajax request pass 3 value input elements value="" field.

ajax call using controller:

$.ajax({     type: 'get',     url: $('#foovalue').data('url'),     success: function (data) {         $('#foovalue').val(data);     } }); 

the data-url equivalent to:

../foocontroller/foodata 

i'm using t4mvc.

return contentresult instead of jsonresult

public virtual contentresult goodata() {     var fooresults = new fooqueries().foototal();     return content(fooresults); } 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -