0

I am developing MVC application. I am trying to pass the data from controller and trying to display using JQuery.

I create the array into Controller and pass it to Jquery using Json.

here is the array...

enter image description here

and here is the code of JQuery.

function getProductDetails(productCode, Index) {
    $.ajax({
        url: "/Product/getProductDetails/",
        data: { Id: productCode },

        dataType: "json",
        success: function (result)
          {


            $.each(result.StockData, function (key, Value) {
                alert(key + "+" + Value);
             });
        }
    });

}

I have displayed the alert for the values... it shows as below... Key shown perfectly but value shows as a object.

enter image description here

3
  • what tool or debugger do you use to show the structure of myArray? Commented May 13, 2014 at 11:02
  • Sorry ? Not getting... Commented May 13, 2014 at 11:05
  • If its not a circular structure you can use JSON.stringify Commented May 13, 2014 at 11:23

1 Answer 1

2

Try to stringify that object,

$.each(result.StockData, function (key, Value) {
  alert(key + "+" + JSON.stringify(Value));
});

According to your new request try like,

$.each(result.StockData, function (key, Value) {
  alert(key + "+" + (Value.Value));
});
Sign up to request clarification or add additional context in comments.

3 Comments

it shows like , 2+{"Key":3,Value":599) ... I em expecting like 2 + 599
@user1650894 sorry that was a typo, now try.. :)
just show your json structure.. what would JSON.stringify(Value) returned..? giv me the entire result not a sample..?

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.