Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript REDIPS将结果作为数组从函数中获取,并将其传递给ajax_Javascript_Php_Jquery_Drag And Drop - Fatal编程技术网

Javascript REDIPS将结果作为数组从函数中获取,并将其传递给ajax

Javascript REDIPS将结果作为数组从函数中获取,并将其传递给ajax,javascript,php,jquery,drag-and-drop,Javascript,Php,Jquery,Drag And Drop,我正在使用REDIPS库,这样我就可以拖放表中的一些元素。按照库提供的示例,我希望将save_content()结果作为数组,以便将这些值插入数据库中。这是我的方法,但不起作用。现在,我在一个显示为文本的输入中获取值 save_content = function (tbl) { var query = '', // define query parameter tbl_start,

我正在使用REDIPS库,这样我就可以拖放表中的一些元素。按照库提供的示例,我希望将save_content()结果作为数组,以便将这些值插入数据库中。这是我的方法,但不起作用。现在,我在一个显示为文本的输入中获取值

            save_content = function (tbl) {
                    var query = '',     // define query parameter
                    tbl_start,      // table loop starts from tbl_start parameter
                    tbl_end,        // table loop ends on tbl_end parameter
                    tbl_rows,       // number of table rows
                    cells,          // number of cells in the current row
                    tbl_cell,       // reference to the table cell
                    t, r, c, d;     // variables used in for loops
                    // first sort tables array to it's original order
                    tables.sort(function (a, b) {
                        return a.idx - b.idx;
                    });
                    // if input parameter is undefined, then method will return content from all tables
                    if (tbl === undefined) {
                        tbl_start = 0;
                        tbl_end = tables.length - 1;
                    }
                    // if input parameter is out of range then method will return content from first table
                    else if (tbl < 0 || tbl > tables.length - 1) {
                        tbl_start = tbl_end = 0;
                    }
                    // else return content from specified table
                    else {
                        tbl_start = tbl_end = tbl;
                    }
                    // iterate through tables
                    for (t = tbl_start; t <= tbl_end; t++) {
                        // define number of table rows
                        tbl_rows = tables[t].rows.length;
                        // iterate through each table row
                        for (r = 0; r < tbl_rows; r++) {
                            // set the number of cells in the current row
                            cells = tables[t].rows[r].cells.length;
                            // iterate through each table cell
                            for (c = 0; c < cells; c++) {
                                // set reference to the table cell
                                tbl_cell = tables[t].rows[r].cells[c];
                                // if cells isn't empty (no matter is it allowed or denied table cell)
                                if (tbl_cell.childNodes.length > 0) {
                                    // cell can contain many DIV elements
                                    for (d = 0; d < tbl_cell.childNodes.length; d++) {
                                        // childNodes should be DIVs, not \n childs
                                        if (tbl_cell.childNodes[d].tagName === 'DIV') { // and yes, it should be uppercase
                                            var value = $(tbl_cell).find("input").val();

                                            query += 'p[]=' + tbl_cell.childNodes[d].id //obj id
                                            + '_' + value + '_' + r + '_' + c + '&';
                                        }
                                    }
                                }
                            }
                        }
                    }
                    // cut last '&'
                    query = query.substring(0, query.length - 1);
                    // return prepared parameters (if tables are empty, returned value could be empty too)
                    return query;
                };
}

我在输入中以文本形式获取值

update.php

if (isset($_POST['submit'])){
 if(isset($_POST['moverCitaRow'])){
  if (!empty($_POST['moverCitaRow'])) {

  $content = $_POST['moverCitaRow'];

  $content = @$_REQUEST['p'];

  if(is_array($content)) {
    foreach ($content as $c) {
      list($job_id, $job_bay_id, $row, $col) = explode('_', $c);

      try {
        update_calendar($job_id, $job_bay_id, $row, $col);

      } catch (Exception $ex) {
        $_SESSION["errorMsg"] = $ex->getMessage();
        $_SESSION["errorType"] = "danger";
      }
    }
  }

}

else {
  echo '<center><strong style="color:red;">Llenar todos los campos 
    requeridos</strong></center><br>';
}
if(isset($\u POST['submit'])){
如果(isset($_POST['moverCitaRow'])){
如果(!空($_POST['moverCitaRow'])){
$content=$_POST['moverCitaRow'];
$content=@$_请求['p'];
if(is_数组($content)){
foreach($c内容){
列表($job\u id、$job\u bay\u id、$row、$col)=分解(''u',$c);
试一试{
更新日历($job\u id、$job\u bay\u id、$row、$col);
}捕获(例外$ex){
$\会话[“errorMsg”]=$ex->getMessage();
$\会话[“errorType”]=“danger”;
}
}
}
}
否则{
echo'Llenar todos los campos
重新提问
'; }
} }

if (isset($_POST['submit'])){
 if(isset($_POST['moverCitaRow'])){
  if (!empty($_POST['moverCitaRow'])) {

  $content = $_POST['moverCitaRow'];

  $content = @$_REQUEST['p'];

  if(is_array($content)) {
    foreach ($content as $c) {
      list($job_id, $job_bay_id, $row, $col) = explode('_', $c);

      try {
        update_calendar($job_id, $job_bay_id, $row, $col);

      } catch (Exception $ex) {
        $_SESSION["errorMsg"] = $ex->getMessage();
        $_SESSION["errorType"] = "danger";
      }
    }
  }

}

else {
  echo '<center><strong style="color:red;">Llenar todos los campos 
    requeridos</strong></center><br>';
}