Ajax function not working

前端 未结 2 1486
被撕碎了的回忆
被撕碎了的回忆 2020-12-22 14:01

Ajax function not updating the data. Data load in dialogbox of bootstrap and i need to update the data with changes.i also check in browser the value is come from dialog box

2条回答
  •  庸人自扰
    2020-12-22 14:41

    I think you should post your data without stringifying your JSON:

    $("#UpdateTbl").click(function () {
        var id = $(this).attr("edit-id");
        var user = {};
        debugger;
        user.DayDesc = $("#DaybookDesc1").val();
        user.VoucherNo = $("#Prifix1").val();
        user.VoucherNo1 = $("#Surffix1").val();
    
    
        $.ajax({
            type: "Post",
            contentType: "application/json; charset=utf-8",
            url: "DaybookMast.aspx/UpdateData",
            data: {"objEmployee": user, "eid": id},
            dataType: "json",
            success: function (data) {
                if (confirm("Are you want to change !") == true) {
                    alert("Updated successfully");
                } else {
                    alert("canceled changes");
                }
            },
            error: function (data) {
                alert("Error while Updating data of :" + id);
            }
        });
    });
    

    On a side note: don't do SQL injection in your DB statements... Use parameters instead to avoid possible security breaches. More info @ https://stackoverflow.com/a/6548006/2805121

提交回复
热议问题