JQuery 可编辑从数据库中选择数据

任何人都可以在这种情况下提供帮助,我有一个选择标记,其中使用 Ajax POST 方法从 SQL 数据库加载数据。


我的代码在下面,但它不能正常工作,但也没有显示任何错误。我正在使用可编辑的选择来实现这一点。任何帮助将不胜感激。


链接


        <link rel="stylesheet" href="https:rawgithub.com/indrimuska/jquery-editable-select/master/dist/jquery-editable-select.min.css" />

        <script src="https://rawgithub.com/indrimuska/jquery-editable-select/master/dist/jquery-editable-select.min.js"></script>

AJAX


     $.ajax({

        type: "POST",

        contentType: "application/json; charset=utf-8",

        // url: "SerialNumberCapture.aspx/GetAllCompanyDetails",

        url: "ViewSerialNumbers.aspx/ViewGetAllTransactionID",

        data: "{CompanyCode:'" + companycode + "',TransactionType:'" + transype + "'}",

        dataType: "json",

        success: function (data) {

            //$('#ddlViewTransactionType option:not(:first)').remove();


            $("#ddltransactionId").empty().append("<option value='0'>Select</option>");

            //$("#ddltransactionId").empty();

            $.each(data.d, function (key, value) {


                $("#ddltransactionId").append($("<option></option>").val(value.TransId).html(value.TransId));


            });

            $('#ddltransactionId').editableSelect();


          },

        error: function (result) {

            alert("Failed: " + result.status + ": " + result.responseText);

        }

       });


长风秋雁
浏览 140回答 2
2回答

小唯快跑啊

我认为这个问题是由<b> &nbsp;$('#ddltransactionId').editableSelect();</b>你不能在 JavaScript 中以这种方式写入 html 标签这一行引起的。在这里你应该只是打电话$('#ddltransactionId').editableSelect();。

月关宝盒

对于那些可能遇到过这个问题的人,我发布了一个解决这个问题的解决方法。它仅支持 HTML5&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <input type="text" list="ddltransactionId" id="txtTransactionId" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <datalist id="ddltransactionId">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <option value="0">Select</option>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </datalist>谢谢。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript