0

I am not understand this case:

I have a model like:

public class ExmDescobertos {
    public int Id { get; set; }
    public int ExameId { get; set; }
    public int PlanoId { get; set; }
    public int ConvenioId { get; set; }
}

And create an object javascript:

var objDescoberto = new Object();
objDescoberto.Id = $("#hdnDescobertoId").val(); //inputs with values...
objDescoberto.ExameId = $('#hdnExameId').val();
objDescoberto.PlanoId = $('#hdnPlanoId').val();
objDescoberto.ConvenioId = $('#hdnConvenioId').val();

And I am using Json.stringify(obj) to transmit the values with a $.post jQuery method:

var dados = JSON.stringify(objDescoberto);

In this point, dados is "{"Id":"27","ExameId":"53","PlanoId":"32","ConvenioId":"11"}", for example.

And have a controller with this action:

public PartialViewResult(ExmDescobertos descoberto) { }

But... the parameter in this controller not receive your values correct! :o In this point descoberto is Id = 0; ExameId = 0; PlanoId = 0; ConvenioId = 0;

Not errors explicit, but not works... Anybody have a idea of what I have missing? Thank you for all!

2
  • Can you use the browser's developer tools or Fiddler to see what the browser is actually sending? Commented Apr 10, 2014 at 14:08
  • How do you send that data? I mean can you post the javascript that makes the ajax call? Commented Apr 10, 2014 at 14:16

1 Answer 1

1

Don't stringify you object, just send object as is.

$.post("/url", objDescoberto);

or

var dados = JSON.stringify({descoberto : objDescoberto});
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks @Ilya. Now, all wokrs vine. Great! ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.