doug48
1/12/2016 - 9:43 AM

ajax script that sends data and receives as json, then uses $.each to iterate the json. The json would have create as an array on converted

ajax script that sends data and receives as json, then uses $.each to iterate the json. The json would have create as an array on converted to json

                $.ajax({
                    url: url,
                    type: 'POST',
                    data: {order: orderNum},
                    dataType: 'json',
                    success: function (response) {
                        console.log(response.order.status);
                        $('td.status').html(response.order.status);
                        $('td.total').html(response.order.grand_total);
                        $('td.invoiced').html(response.order.total_invoiced);
                        var itemHtml = '';
                        $.each(response.items, function(i, item){
                            itemHtml = itemHtml + '<tr><td>' + item.sku;
                            itemHtml = itemHtml + '</td><td>' + item.item_id;
                            itemHtml = itemHtml + '</td><td>' + item.price + '</td></tr>';
                        })
                        $('table.items').append(itemHtml);


                    }
                });