0

我正在尝试使用基于员工 ID 的 ajax 调用在文本框中的 asp x 页面中显示结果。我已将 Sql 查询编写为 Web 方法来获取结果。它返回记录列表<>。我想通过 Sql 查询在输入文本框中使用 JavaScript ajax 调用在 asp x 页面上显示结果。例如 dB 表名称是包含名字、姓氏、电子邮件的员工记录。我想通过 Web 方法中的 Sql 查询获取记录,然后想通过 ajax 调用显示。

$.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: "http://localhost:12897/Methods.asmx/GetEmployeeById",
                data: '{"pid": "' + value + '"}',
                dataType: "json",
                async: false,
                success: function (msg) {

                    response = true;
                    $('#testerror').html();// i want query result here in text box with id testerror
                    $('#confirmModal').modal();

                },
                error: function (result) {

                    alert("please try again");
                    return false;

                }

            });
4

1 回答 1

0

$('#testerror').html(msg.d);

试试这个,它将从服务器获取响应并将其放入您的测试错误中。假设 testerror 是一个具有 .html 属性的对象。

如果这不起作用,您可以尝试 .val(msg.d) 而不是 .html(msg.d)


这将显示来自您的服务器调用的响应。如果您需要将它们格式化为 HTML 表格,请澄清这一点。

于 2013-10-03T17:10:34.923 回答