ajax 設定 FormData() 傳遞陣列
// 1. 取得勾選項目var items = [];$.each($(“.select-export:checked”), function(){items.push($(this).val());});var form_data = new FormData();form_data.append(‘ids’, items);// 2. 匯出$.ajax({url: “/Product/export”,type: “POST”,dataType: “text”,data: form_data,contentType: false,processData: false,success: function(data) {},error: function(XMLHttpRequest, textStatus, errorThrown) {}});
PHP Controller 接值 (use codeigniter)
$_REQUEST[‘ids’];