Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在jquery drop函数中编写JSTLSQL查询?_Jquery_Html_Jsp_Jstl - Fatal编程技术网

在jquery drop函数中编写JSTLSQL查询?

在jquery drop函数中编写JSTLSQL查询?,jquery,html,jsp,jstl,Jquery,Html,Jsp,Jstl,每当一个元素被放入一个Dropable中时,我就想访问数据库并输出我从他们的ID中得到的东西 drop: function(event,ui){ $(ui.draggable).detach().css({top:0,left:0}).appendTo($(this)); $(ui.draggable).detach().css({top:0,left:0}).appendTo($(this)); var slotid=$(this).attr("id");

每当一个元素被放入一个Dropable中时,我就想访问数据库并输出我从他们的ID中得到的东西

 drop: function(event,ui){
     $(ui.draggable).detach().css({top:0,left:0}).appendTo($(this)); 
     $(ui.draggable).detach().css({top:0,left:0}).appendTo($(this));
     var slotid=$(this).attr("id");
     var courseid=$(ui.draggable).attr("id");
     //Using the above two variables I want to get(and also change) something from(in) the database
 }
但是在这里插入jstl函数会产生一个错误,我无法从前面的问题中找到任何有用的方法来解决我的问题


有人能给点提示吗。

为什么不试试ajax呢?哪个更适合你的问题

drop: function (event, ui) {                                      
    $.ajax({
        type: "POST",
        data: { slotid: $(this).attr("id"), courseid: $(ui.draggable).attr("id");},
        url: 'ServletURL',
        success: function (data) {
            alert(data);
        }
    });
}
您只需创建单独的函数,用以下参数查询数据库

String slotid = request.getParameter("slotid");
String courseid = request.getParameter("courseid");

希望这能有所帮助。

我需要创建一个单独的页面来更新和获取值,还是需要在同一页面中创建函数,以及如何在同一页面中创建函数@您不必创建单独的页面。在您的下拉列表中使用此函数,并创建一个单独的servlet来从中返回数据。