来自ajax的控制台日志响应返回整页而不是字符串

时间:2016-10-20 14:16:46

标签: javascript php jquery ajax

我想根据select标签中的内容过滤表中的行。

我创建了一个在更改选项时触发的函数。它将表中的信息保存在二维数组中。 这是看起来如何。

array

现在我想使用ajax和post方法将数组从jquery转换到php,但即使目标文件为空,我也无法返回成功。

如果我在console.log中显示响应,则显示此

response

以下代码



< script type = "text/javascript" >
  function sortare() {
    var optiuneSortare = $('#protopopiat option:selected').text(); //get the chosen option
    var dateGenerale = new Array(); //the array in which i store the text from the table
    $("tr").each(function() {
      var date = new Array();
      var $id = $(this).find('th');
      var $valoareId = $id.html();
      date.push($valoareId);

      $(this).find('td').each(function() {
        var $nume = $(this).attr('data-head');
        var $valoare = $(this).html();
        if ($nume != undefined) {
          date.push($valoare);
        } else {
          date.push($valoare);
        }
      });
      dateGenerale.push(date);
    });
    console.log(dateGenerale);// this console.log return an array as it should

    $.ajax({
      type: 'post',
      url: 'sortare.php',
      dataType: "html",
      data: {
        tabel: dateGenerale,
        optiune: optiuneSortare
      },
      success: function(response) {
        console.log(response);// this console.log return the whole page
      }
    })
  } < /script>
&#13;
<tr>
  <th class="check-column" scope="row">
    <input id="cb-select-60" type="checkbox" name="del_id[]" value="60">
  </th>
  <td data-head="Nume">-</td>
  <td data-head="Prenume">-</td>
  <td data-head="Parohia">Sf. Ioan Domnesc, Bicaz Oras I</td>
  <td data-head="Hram">-</td>
  <td data-head="Protopopiat">Protopopiatul Piatra Neamț</td>
  <td data-head="Judetul">Neamt</td>
  <td data-head="Localitate">-</td>
  <td data-head="Strada">-</td>
  <td data-head="Nr. Strada">-</td>
  <td data-head="Telefon">0767000000</td>
  <td data-head="Email"></td>
  <td data-head="Ruta pelerinaj">Israel</td>
  <td data-head="Data inceput">13.10.2015</td>
  <td data-head="Data sfarsit">20.10.2015</td>
  <td data-head="Numar Pelerini"></td>
  <td data-head="Prestator"></td>
  <td data-head="Ghid">Pr. Paroh</td>
  <td data-head="IP-up aplicantului">94.177.46.1</td>
  <td data-head="Data aplicarii">2016-10-17 11:56:32</td>
  <td data-head="Nume Cont">5</td>
  <td><a data-rid="60" href="#TB_inline?width=600&amp;height=550&amp;inlineId=cf7d-modal-edit-value" class="thickbox cf7d-edit-value">Editează</a>
  </td>
</tr>
&#13;
&#13;
&#13;

&#13;
&#13;
<?php
$tabel2 = $_POST['tabel'];
$termen = $_POST['optiune'];
echo "test";
?>
&#13;
&#13;
&#13;

我从来没有遇到过这个问题。 有谁知道为什么会这样?

0 个答案:

没有答案