Avatar of Moti Mashiah
Moti Mashiah
Flag for Canada asked on

Json and ajax

Hi guys,
I'm about to lose my mind :).

I have asp.net mvc project and I'm returning json to ajax call from the controller.
Look at my backend method:
public JsonResult Nexttostep8(string manu)
var supllst = (from i in dbh.Items
                               join s in dbh.SupplierLists on i.ID equals s.ItemID
                               join sa in dbh.Suppliers on s.SupplierID equals sa.ID
                               where i.ItemLookupCode == "050326120180"
                               select new

                foreach (var item in supllst)
                    var i = new suppliersmodel();
                    i.SupplierName = item.SupplierName;
                    i.ReorderNumber = item.ReorderNumber;
                    i.MinimumOrder = item.MinimumOrder;
                    i.MasterPackQuantity = item.MasterPackQuantity;
                    i.Customtext5 = item.CustomText5;

                    if (item.CustomText5 == "LOCAL")
                        i.Cost = item.Cost;
                        i.LocalCost = item.Cost;
                        i.Cost = item.Cost;
                        i.LocalCost = item.Cost * Convert.ToDecimal(0.84);

return Json(lstsupliers, JsonRequestBehavior.AllowGet);

Open in new window

Here is my ajax call example:
function Nexttostepeight() {
    var manu = $("#textmanufactureid").val();
        type: "POST",
        url: "/PIM/Nexttostep8",
        dataType: "json",
        data: { manu: manu },
        success: function (data) {
            $('#step7').css('backgroundColor', '#2ECCFA')
            $('ul.setup-panel li:eq(7)').removeClass('disabled');
            $('ul.setup-panel li a[href="#step-8"]').trigger('click');
            $("#manufacturerprogresid").show().html("<strong>MANUFACTURER:</strong> " + manu);
            var suplier = '';
            for (var i = 0; i < data.length; i++) {
                var dt1 = data[0].SupplierName;
                var dt2 = data[1].ReorderNumber;
                var dt3 = data[2].MinimumOrder;
                var dt4 = data[3].MasterPackQuantity;
                var dt5 = data[4].Customtext5;
                var dt6 = data[5].Cost;
                var dt7 = data[6].LocalCost;

Open in new window

The issue I'm facing here is - I'm getting the first properties just fine, but the rest come with error.
"Cannot read property 'MinimumOrder' of undefined"

Please, HELP.

Avatar of undefined
Last Comment
Moti Mashiah

8/22/2022 - Mon
Moti Mashiah

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes