How can I send a text area content to my server?

262 views Asked by At

I have been studying about ajax and this as far as I can get, I would like to send the text area's content to my server and save it in a text file, but I'm a little bit confused on how to do it, BTW my server is apache tomcat. I've heard that I need a piece of code on server side. Can you help me?

Thanks in advance.

$(document).ready(function() {
  var data = new FormData();
  var cssData = $("#custom-css-text").val();
  data.append("custom_css", cssData);
  $.ajax({
    url: 'myserver',
    type: 'POST',
    data: {value:data},
    cache: false,
    dataType: 'json',
    processData: false,
    contentType: false,
    success: function(response) {
      alert(cssData);

    },
    error: function(jqXHR, textStatus, errorThrown) {
      alert('ERRORS: ' + textStatus);
    }
  });

});
#custom-css-text {
  border-style: outset;
}
<!DOCTYPE html>
<html>

<head>
  <title>HTML5, CSS3 and JavaScript demo</title>
</head>

<body>

  <textarea id="custom-css-text">testing</textarea>

</body>

</html>

0

There are 0 answers