When I get the div value, how do I get the input, and send it out by POST?

I have a terrible thing right now.
I have an editor
, which is edited on DIV
, so I want his HTML code hypothetically, and I find that it is used:
var html = document.querySelector (".ql-editor"). InnerHTML;

).

then when the list POST is out
my console.log can print out the results. There is no problem

my jquery structure looks like this

var formData = new FormData($("-sharpform")[0]);

clipboard.png

there is no problem with other input
only $content has a problem! He will be empty


      "UPDATE `news` SET
      `content` = "".$_POST["content"].""
      WHERE `id` = "".$id."" "

I have added Tibetan input to the list

<input type="hidden" name="content" id="content">

then do this at jquery:

$("-sharpcontent").val(html);

but this method does not work at all.
he will be empty!
but the problem is that I console.log printed html he is worth it!
what is the problem?


is it $("- sharpcontent"). Before Val (html); is rendered on dom, var formData = new FormData ($("- sharpform") [0]); try to write this


.
var html = document.querySelector(".ql-editor").innerHTML;
var formData = new FormData($("-sharpform")[0]);
formData('content',html);

new formData can pass in a form tag, and all form elements within the form tag that carry the name attribute will be considered formItem .

form elements contain the following (there may be others, but less commonly used, 2333):

  1. input
  2. textarea

if you are sure that the source of your data is a div , then I'm sorry that direct new FormData won't get the results you want.
you need to do the following append operation:

.
formData.append('content', document.querySelector(".ql-editor").innerHTML)
Menu