Ajax未发送到数据库[重复]

This question already has answers here:
                </div>
            </div>
                    <div class="grid--cell mb0 mt4">
                        <a href="/questions/4261133/notice-undefined-variable-notice-undefined-index-and-notice-undefined" dir="ltr">“Notice: Undefined variable”, “Notice: Undefined index”, and “Notice: Undefined offset” using PHP</a>
                            <span class="question-originals-answer-count">
                                (28 answers)
                            </span>
                    </div>
            <div class="grid--cell mb0 mt8">Closed <span title="2017-08-10 16:18:43Z" class="relativetime">2 years ago</span>.</div>
        </div>
    </aside>

I am trying to submit my form with ajax and cant seem to get it to work. I have tried different methods but data is still not sent to database. Below is my code

form

<form action='sendquestion.php' method='post' id="sendQform" enctype="multipart/form-data">
    <input type='text' name='searchQuestion' id='searchQuestion'placeholder='Enter your question'><br>
    <input type="text" name="user" id="user" value="<?php echo ''.$_SESSION['log_id'].'';?>" style="display: none">
    <input type="text" name="qDate" id="qDtae" value="<?php echo date('d/M/Y');?>" style="display: none">
    <input type="text" name="status" id="status" value="0" style="display: none">
    <label for='sendSearchQuestion'><i class='fa fa-send'></i></label>
    <input type="submit" name="sendSearchQuestion" id="sendSearchQuestion" value="Send">
</form>

Ajax

$('#sendQform').submit(function(e) {
    e.preventDefault();
    var $form = $(this), url = $form.attr("action");

    var posting = $.post(url, {searchQuestion: $('#searchQuestion').val(), user: $('#user').val(), status: $('#status').val(), qDate: $('#qDate').val()});
    posting.done(function(data) {
        alert("success");
    });
});

PHP

<?php
session_start();
require_once ("db.php");
$db = new MyDB();

if (isset($_POST['sendSearchQuestion']))
{
    $question = strip_tags(@$_POST['searchQuestion']);
    $askid = htmlentities($_POST['user'], ENT_QUOTES, 'UTF-8');
    $status = strip_tags(@$_POST['status']);
    $date = htmlentities($_POST['qDate'], ENT_QUOTES, 'UTF-8');

    $sql = $db->prepare("INSERT INTO userquestions (userid, question, status, dates) VALUES (?, ?, ?, ?)");
    $sql->bindParam(1, $askid, SQLITE3_INTEGER);
    $sql->bindParam(2, $question, SQLITE3_TEXT);
    $sql->bindParam(3, $status);
    $sql->bindParam(4, $date);

    $result = $sql->execute();

    if ($result)
    {
        echo "true";
    }
    else
    {
        echo "false";
    }
}
?>

Why is this not working. Thanks.

</div>

You logic test is for sendSearchQuestion and your fild is searchQuestion

Change

if (isset($_POST['sendSearchQuestion']))

to

if (isset($_POST['searchQuestion']))