Php 我找不到我的错误;Ajax请求返回空值

Php 我找不到我的错误;Ajax请求返回空值,php,mysql,ajax,response,Php,Mysql,Ajax,Response,这是我的来源;哈哈 $(document).on('click', '#findFirstUndefined', function (event) { event.preventDefault(); $.ajax({ type: 'post', url: './custom/tool.node.php', dataType: 'text', data: {

这是我的来源;哈哈

 $(document).on('click', '#findFirstUndefined', function (event) {
       event.preventDefault();
       $.ajax({
           type: 'post',
           url: './custom/tool.node.php',
           dataType: 'text',
           data: {
               m: 't',
               f: 'fu'
           },
           beforeSend: function () {
               console.log('Request find first undefined node..');
           },
           success: function (data) {
               console.log('Request success.');
               console.log(data);
           },
           error: function () {
               console.log('Request failure.');
           }
       });
   });
    // Following is tool.node.php
   if ($_POST['m'] === 'n') {
       if (createNode($db)) echo $db - > insert_id;
       else echo 'false';
   }
    // ..
    else if ($_POST['m'] === 't') {
       if ($_POST['t'] === 'fu') {
           // Find first undefined node..
           $sql = "select `id` from `v3_node` where `type`=0 limit 0,1;";
           $rst = $db - > query($sql);
           // Initialize array for json string
           $return = array('rstExist' = > null);
           if ($rst - > num_rows === '0') {
               // Undefined Node NOT exist.
               $return['rstExist'] = false;
           } else {
               // Undefined Node exist.
               $return['rstExist'] = true;
               // Find 20 items around first undefined node.. 
               $row = $rst - > fetch_assoc();
               $sql = "select * from `v3_node` where `id`>=".($row['id'] - fmod($row['id'], 20) + 1).
               " limit 0, 20;";
               $rst = $db - > query($sql);
               $return['node'] = array();
               while ($row = $rst - > fetch_assoc()) {
                   array_push($return['node'], $row);
               };
           };
           echo json_encode($return);
       };
   };
我只想通过ajax获取行,而响应为空。。里面什么都没有。我甚至找不到我的错误,所以需要帮助

而且,如果我将数据类型属性更改为“json”,控制台将打印请求失败,这是错误回调;为什么会这样?

在这行数据之后:{m:t',f:fu'},。它将执行else语句,因为m=='t'

在这个else语句中,它需要是t=='fu',但这不是真的,因为$u POST['t']不存在。我认为这应该是f而不是t。因此,改变这一行:

if($_POST['t'] === 'fu') {


我想说,你的url与你的文件夹结构不匹配。你为什么有一个好朋友。在./custom/tool.node.php前面?它指的是什么?或者别的什么地方?这只是一个相对的url,我写这个问题的时候不太在乎它,所以如果你点击这个链接,它就不起作用了;!心理崩溃序列已启动..3..2。。谢谢你的回答。这帮了大忙!没问题。如果我的答案有用,请通过接受我的答案或删除问题来结束问题!
if($_POST['t'] === 'fu') {
if($_POST['f'] === 'fu') {