-1

I'm a total programming rookie and I really can't get my JSP to send ANYTHING to my servlet. I'm pretty sure the servlet's ok but I have NO IDEA what my submit button in the asp is trying to send to it. It currently looks like this:

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Sortable - Drop placeholder</title>
<link rel="stylesheet"
    href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<style>
#sortable {
    list-style-type: none;
    margin: 0;
    padding: 0;
    width: 60%;
}

#sortable li {
    margin: 0 5px 5px 5px;
    padding: 5px;
    font-size: 1.2em;
    height: 1.5em;
}

html>body #sortable li {
    height: 1.5em;
    line-height: 1.2em;
}

.ui-state-highlight {
    height: 1.5em;
    line-height: 1.2em;
}
</style>
<script>
var sortableLinks = $("#sortable");
var linkOrderData = $(sortableLinks).sortable('serialize');
var formData =new FormData($(this)[0]);

$( document ).ready(function() {
      $('form').on('submit', function (event) {
         event.preventDefault();






     $.ajax({
    url: 'sortcv',
    type: 'POST',
    data: formData,
    async: false,
    cache: false,
    contentType: false,
    processData: false,
    success: function (returndata) {
      alert(returndata);
  }

  });
     return false;
  });
      $( "#sortable" ).sortable({
          placeholder: "ui-state-highlight"
        });
        $( "#sortable" ).disableSelection();
      });



  </script>
</head>
<body>
    <form role="form" id="data">
        <ul id="sortable">
            <li id="1" value ="one" class="ui-state-default">CV1</li>
            <li id="2" value ="two" class="ui-state-default">CV2</li>
            <li id="3" value ="three" class="ui-state-default">CV3</li>
        </ul>
        <input type = "submit" value="sortcv" name = "sortcv"/>
    </form>


</body>

  • I think nothing will be send to the server because from doesn't contain any input component. – Braj May 17 '14 at 15:57

1 Answers1

2

You're not sending any data to the server. The data should be explicitly set in <input> fields and known by the name attribute:

<form role="form" id="data">
    <ul id="sortable">
        <li id="1" value ="one" class="ui-state-default">CV1</li>
        <li id="2" value ="two" class="ui-state-default">CV2</li>
        <li id="3" value ="three" class="ui-state-default">CV3</li>
    </ul>
    <input type="text" name="one" value="one" />
    <input type="text" name="two" value="two" />
    <input type="text" name="three" value="three" />
    <input type = "submit" value="sortcv" name = "sortcv"/>
</form>

Note that <ul> data is not sent to the server because it is not a user input component.

Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332
  • Ok. Thank you :). So, is there even a way to get the list's order to the servlet? – user3647958 May 17 '14 at 16:04
  • @user3647958 looks like you still don't understand that the values in the `
      ` won't be sent to the server. The only thing you can send are `` and `
    – Luiggi Mendoza May 17 '14 at 16:05