2
How do I get the attributes of an object that is returned by a action in the javascript?
This is my code ajax.
Step the id for the action and it returns an object. I would like to access the values of that object.
function UpdateDataPortfolio(id) {
var parametros = {
cd: id,
};
$.ajax({
type: "POST",
url: "/ManagementTables/UpdateDataPotfolio",
data: parametros,
datatype: "html",
success: function (data) {
alert(data);
},
error: function () {
alert('failure');
}
});
}
That’s the action:
[HttpPost]
public Portfolio UpdateDataPotfolio(String cd)
{
if (cd != null)
{
Portfolio port = portfolio.ListbyId(cd);
return port;
}
return new Portfolio();
}
There is still the
JsonResult
, which I consider better than theActionResult
for this case.– Leonel Sanches da Silva
I got it using Json. Thank you
– Paulo
@Gypsy omorrisonmendez good option also.
– DontVoteMeDown
@Paul if this is the answer to the question, please mark it as such.
– DontVoteMeDown