I have a JavaScript object, and converted it into JSON using Douglas Crockford's JSON utility. While sending a post AJAX request, I get:
REXML::ParseException does not have a valid root
REXML::ParseException (The document "{\"name\":\"asda\",\"deadline\":\"May 24, 2011\"}" does not have a valid root):
I am not able to proceed with this error.
When making your AJAX request, you're probably sending the wrong Content-Type header. If you make a request with the header Content-Type: application/xml
, Rails will try to parse your request body as XML, and you'll get that error message. Instead, you'll want to use application/json
or another content-type so that Rails won't try to parse it. If you're using jQuery, this is the contentType
setting in $.ajax.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With