为什么我的 javascript 正在调用回发而我没有错误?

Why my javascript is calling a postback and i don't have error?

当我按下我的编辑按钮时,我调用了一个网络服务函数,它 return 一个问题参数列表,它正在运行函数 return 每个编辑按钮的正确值,但在 returning 我有一个 post 返回的值和我在这个函数中填写的所有 html 输入它们又清楚了,为什么?

JavaScript 和 jQuery:

$(document).ready(function () {
    $('.divPreview').on("click", ".editbtn", function () {
        var idQ = 0;

        idQ = $(this).val();
        var Did = { 'Qid': idQ };
        alert(idQ);

        $.ajax({
             type: "POST",
             async: false,
             url: "/WebService.asmx/GetQuestion",
             data: JSON.stringify(Did),
             contentType: "application/json; charset=utf-8",
             dataType: "json",
             success: OnSuccess,
             error: function (r) {
                 alert(r.responseText);
             },
             failure: function (r) {
                 alert(r.responseText);
             }
        });

        function OnSuccess(response) {

            var question = response.d;

            $(".dropdown_fields").html('<select id="dplQuestionType" class="dropdown_selector"><option value="radio">Radio Button</option> <option value="checkbox">Check Box</option></select>');
            $(".input_field").html('<p>Q1:<input id="txtQuestion" type="text" /></p> <p> Answer Choices:</p><div><input id="hdnC1" type="hidden" value="0" /><input id="txtC1"type="text" name="mytext[]" /><input id="cbActive1" type="checkbox" /></div><div><input id="hdnC2" type="hidden" value="0" /><input id="txtC2" type="text" name="mytext[]" /><input id="cbActive2" type="checkbox" /></div>');
            $(".OtherOption").html('<input id="btnAddField" class="btnAddField" type="button" value="Add Choices"/><br>Page Number<input id="txtPageNumber" type="text" /> Question Order: <input id="txtOrder" type="text" /><br/><p><input id="cbCommonField" type="checkbox" />Add a Common Field</p><br/>Is Required<input id="cbIsRequire" type="checkbox" />Is Active<input id="cbIsActive" type="checkbox" /><br/>Hint:<textarea id="txtaHint" rows="2" cols="20"></textarea> ');
            $(".ButtonField").html('<p><input id="btnSave" type="button" value="Save" onclick="GetQuestionInfo()" />&nbsp;&nbsp;&nbsp;<input id="btnCancel" class="btnCancel" type="button" value="Cancel" /></p>');


            document.getElementById("btnAddQuest").style.visibility = 'hidden';
            document.getElementById("txtOrder").value = question.qst_Order;
            document.getElementById("txtPageNumber").value = question.qst_PageNumber;
            document.getElementById("cbIsRequire").value = question.qst_Order;
            document.getElementById("cbIsActive").value = question.qst_Order;
            document.getElementById("txtaHint").value = question.qst_Hint;
            document.getElementById("dplQuestionType").value = question.qst_Type;
            document.getElementById("hdnQuestionID").value = question.qst_Id;

            alert(question.qst_txt);
        }
    });
});

你实际上并没有在做一个 ajax 请求你只是在做一个普通的 post 表单请求,做一个 ajax 请求阻止默认提交使用 e.preventDefault();

$('.divPreview').on("click", ".editbtn", function (e) {
e.preventDefault();