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

如何打印到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 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记