dtsc1684 2019-05-20 13:49
浏览 886
已采纳

如何打印到ajax函数中每行代码的控制台返回值?

I want to see the return value of each line of code in an ajax function. The below code gives me error 1 and e. Now I want to check exactly what is causing the error by printing the return value of each line of the function. Here's the code:

<script type="text/javascript">
function editTitleModalSubmit(titleId) {
    console.log("1");
    event.preventDefault();
    $.ajax({
        url: 'functions/administration-functions.php',
        type: 'POST',
        data: { "title": $('#editadminTitle').val(), "units": $('#editadminUnits').val(), "category": $('#editadminCategory').val(), "titleId": $('#adminTitleId').val(), "typeId": $('#adminTypeId').val() },
        dataType: "json",
        success: function() {
            $('#adminForm').trigger('reset');
            resultAlert('#adminResult', '#resultAdminContent', '<strong>You data was succefully saved!</strong>', 'alert-success');
        },
        error: function() {
            console.log("e");
        }
    });
}
</script>

administration-functions.php

<?php
    require_once './queries.php';
    $title   = filter_input(INPUT_POST, "title");
    $units    = filter_input(INPUT_POST, "units");
    $category = filter_input(INPUT_POST, "category");
    $typeId   = filter_input(INPUT_POST, "typeId");
    $titleId  = filter_input(INPUT_POST, "titleId");
    echo Queries::editTitle($title, $units, $category, $titleId, $typeId);
?>
  • 写回答

1条回答 默认 最新

  • dongye9453 2019-05-20 13:58
    关注

    You aren't assigning the failure to anything and are reading e as a string. Try replacing the error part of your code with this:

    error: function(error) {
        console.log(error);
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)
  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失