表单onsubmit等待5秒,然后刷新页面?

时间:2017-08-30 14:14:34

标签: javascript jquery

我在提交表单时使用onsubmit属性执行此功能。页面然后停止5秒并刷新。有什么问题?

 <form onsubmit='submitQuestion(quizType, $("#submitQ"), $("#submitA1"), $("#submitA2"), $("#submitA3"), $("#submitA4"), $("#submitCorrect"), $("#submitExpl"), $("#submitAuthor"), $("#submitDesc"), $("#submitDate"))'  method='POST'>

在被调用函数内:

var submitQuestion = function (quizType, questionText, a1, a2, a3, a4, correctIndex, expl, author, desc, date) {
    $.ajax({
        url: "controller.php",
        type: 'POST',
        data: {
            quizType: quizType,
            addq_q: questionText,
            addq_a1: a1,
            addq_a2: a2,
            addq_a3: a3,
            addq_a4: a4,
            addq_correct: correctIndex,
            addq_expl: expl,
            addq_author: author,
                addq_desc: desc,
                addq_date: date,
            },
            success: function(data) {
                console.log(data)
            }
    })
}  

0 个答案:

没有答案