Ajax调用servlet发送表单

时间:2016-07-21 05:48:44

标签: jquery ajax servlets

无法将表单发送到我的servlet,我不知道出错了什么,我的servlet名称是SupportReq,

var formdata = new FormData();
           if($scope.files.length>0){
           formdata.append("attachment0",$scope.files[0]);
           }
           formdata.append("description",$scope.rsp.observations);
           formdata.append("title",$scope.rsp.title);
           $scope.rsp.severity = null;
           $scope.rsp.urgency = 'N';
           formdata.append("secerity",$scope.rsp.severity);
           formdata.append("urgency",$scope.rsp.urgency);
           formdata.append("reviewDate",$scope.date);
           formdata.append("subtopic",subtopictest.id);            

           $.ajax({
                url: 'SupportRequest',
                data: $(".formdata").serialize(),
                contentType: 'multipart/form-data',
                processData: false,
                type: 'POST',
                success: function(data){
                    console.log(data);
                }
            });

这里可能有什么问题?

这是我的web.xml

<servlet>
<servlet-name>SupportRequest</servlet-name>
<display-name>SupportRequest</display-name>
<description></description>
<servlet-class>com.request.SupportRequestCreatorServlet</servlet-class>

1 个答案:

答案 0 :(得分:0)

ajax调用中的这一行:

from itertools import product
result = [elem2 for elem1, elem2 in product(listTwo, listOne) if elem2.startswith(elem1)]

应该是:

data: $(".formdata").serialize(),

有关详情,请查看here

__

Useful DEMO