且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

当HTML值更改时,jsp从MySQL检索数据

更新时间:2023-02-12 11:54:00

成功的幸福令人难以置信. 我做了这样的代码更改

The Happiness of Success is fabulous. I made code changes like this

$(".custodianautocomplete").change(function() {
        var IDSelected = $(this).val();
        var recovered = "Rakesh";
        // $(this).parent("td").next().find("input[name=hall_location]").val("Rakesh") ;
        //window.alert($(this).parent("td").next().find("input[name=hall_location]").val());

        $.ajax({
             url: 'getEmpName.jsp',
             type : 'GET',
             data : {IDSelected: IDSelected},
             async: false,
             success : function(response) {
                recovered = response.trim();
                },
            fail:function (jqXHR, exception) {
                console.log(jqXHR);
                },
        });
        $(this).parent("td").next().find("input[name=hall_location]").val(recovered);
      });

请注意,

fail:function (jqXHR, exception) {
                    console.log(jqXHR);
                    },

这帮助我查看了getEmpName.jsp中的错误.然后在同一文件中,如果将(!resultSet.isBeforeFirst() ) {更改为if (rs.next()){并将return buffer;替换为out.println(buffer);response.trim();以便从响应中删除whitespaces,则我进行了更改.代码以我想要的方式工作.多亏了***.com,我在这里找到了所有可能的调试方法.我不介意代码改进(如果有的话).

This helped me look at errors in getEmpName.jsp. Then in Same file i changed if (!resultSet.isBeforeFirst() ) { to if (rs.next()){ and replaced return buffer; to out.println(buffer); and response.trim(); is necessary to remove whitespaces from response. And the Code Works The way I Want. Thanks to ***.com I found all possible ways to debug here itself. I won't mind code improvements if any.