-1

My AJAX call is sending the following data:

[{"type": "paragraph","subtype": "p","label": "Paragraph"}]

However when I print the data received on the console at the back end I get this:

{ '[{"type": "paragraph","subtype": "p","label": "Paragraph"}]': '' }

Please let me know if there is way to prevent this from happening as the data sent via AJAX is to be inserted into my MongoDB.

Thanks to all in advance!

Alive to die - Anant
  • 70,531
  • 10
  • 51
  • 98
abhimalik
  • 131
  • 1
  • 1
  • 7

1 Answers1

1

You have to set contentType in your ajax like below:-

contentType: "application/json; charset=utf-8",

Reference:-What is content-type and datatype in an AJAX request?

Alive to die - Anant
  • 70,531
  • 10
  • 51
  • 98