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 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥170 如图所示配置eNSP
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上