Ajax没有发布到数据库

时间:2014-05-01 21:26:44

标签: php jquery ajax

我正在努力学习AJAX,而且我无法理解如何在页面外运行的脚本中抛出错误。我无法获取数据来更新我的数据库,但似乎也没有出现错误。我不确定当它在页面上运行时转储和调试,就像在这个AJAX场景中一样。我是AJAX的新手,所以问题也存在。在jquery中是否有使用AJAX来确定它的等价物?

***Update**

    <?php
    if (!empty($_POST['clueOne'])) {
    include "includes/db_conx.php";

            $usernameClue = mysqli_real_escape_string($db_conx, $_POST['usernameClue']);
            $clueOne = mysqli_real_escape_string($db_conx, $_POST['clueOne']);
                // See if that product name is an identical match to another product in the system

                // Add this product into the database now

                $sqls = "UPDATE usersClueGame SET clueOne = '1' WHERE username = $usernameClue;";

                $result = mysqli_query($db_conx,$sqls) or die("Couldn't execute query.");;
                exit();
    }
    ?>

的.js

// =====clue 1====================////////////////// clue 1**********************************************************************========================
$(document).on('click', '.btn-clue', function(){ 
    if($i!=1){
        //checking if textbox has desired value (1 in this case),
        //in your application you would be passing the textbox value to ajax here and making the check at server side
        var $one = $('#oneClueShow');
        var x = $("#clueOneInput").find('input[type=text]').val();
        if(x == 'd' || x == 'dr')

        {
            //if answer correct you should load data from ajax and append it to a container
            $.ajax({
                      type: "POST",
                      url: "includes/post_clue_progress.php",
                      data: { clueOne: "1", usernameClue: "<?php echo $manager; ?>" }
                    })
                  .done(function( msg ) {
                    // msg is any data that is echoed in the php script or output to screen is some way
                    $("#clueWrongOne").hide();
                    $("#mySecondDiv").remove();
                    $("#clueOne").remove();
                    $("#clue1Input").remove();
                    $one.show();
                    $("#clueOneInputCorrect").slideDown('slow').show();
                    $i++;
                  });
        }
        else
        {
            $("#mySecondDiv").remove();
            var mySecondDiv = $('<div id="mySecondDiv"><img src="images/check-x-mark.png" /></div>').show('slow');
            $('#clueWrongOne').append(mySecondDiv);
        }
    }
});

0 个答案:

没有答案