Ошибка сохранения записей в БД - PullRequest
0 голосов
/ 21 мая 2018

Я пытаюсь сохранить данные в моей базе данных (см. Рисунок ниже)

enter image description here

, но я получаю эту ошибку:

TypeError: 'insertCell' вызван для объекта, который не реализует интерфейс HTMLTableRowElement

//ADDING NEW ITEM INTO THE ITEM TABLE
	$(document).on('submit', '#product_form', function(event){
		event.preventDefault();
		//btn_action="add_pricelvl"; //Set variable to call the add new item 
		var valdata = $(this).serialize();	//Array with field value	
		var tax = $('#item_tax').val(); //checkbox tax 
		var taxvalue = $('#item_taxvalue').val(); //inputbox tax
		var tabledets = it_det //Read the detail table
			.rows()
			.data();
		var arr1=[];
		var i=0;
		//Put the datatable rows in the array
		for (i=0; i<tabledets.length; i++){
			arr1[i]=tabledets.rows(i).data();	
		}
							
		//call ajax function and send variable to php file.
		$.ajax({			
			url:'item_action.php',
            method:"POST",
            data:{
				//btn_action:btn_action, I can recovery this value in PHP file
				valdata:valdata,
				tax:tax,
				taxvalue:taxvalue,
				arr1:arr1
				},			
            success : function(data)
            {					
				$('#product_form')[0].reset();
                $('#productModal').modal('hide');
                $('#alert_action').fadeIn().html('<div class="alert alert-success">'+data+'</div>');
				$('#alert_action').fadeIn().html(result);
				$('#action').attr('disabled', false);
                $('#item_data').DataTable().ajax.reload();                
            },
			error : function () {
				$('<div>').html('Found an error!');
			}
		})
	});
<div class="row">
  <div class="col-sm-12 table-responsive">
    <table id="item_pricelvl" class="table table-bordered table-striped">
      <thead>
        <tr>												
          <th>Price Level</th>
          <th>Pricing Method</th>									
          <th>From Quantity</th>
          <th>To Quantity</th>									
          <th>Discount Amount</th>									
          <th>Unit Price</th>
          <th><input type="checkbox" class="checkall" /></th>												
        </tr>
      </thead>																	
    </table>
  </div>
</div>

Как я могу скопировать датируемое содержимое в массив для сохранения данных в php-файле ????Я должен сделать по-другому?


Решено

for (i=0; i<tabledets.length; i++){
  arr1[i]=tabledets.row(i).data();	
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...