I am trying to make a POST request to my Sinatra application, but I have problems. Essentially, I have an input field that on submit does something similar in JS:
$.post("/", { info: "some_info"});
who receives a sinatra like this:
post '/' do data = JSON.parse(request.body.read) end
However, the terminal says:
JSON::ParserError - 706: unexpected token at '"info=some_info"':
This means that it is explicitly receiving information on the server side, but I'm not sure why it is throwing this error. I have never used AJAX before. I'm not sure that one day I will receive information on how I should get what I need.
source share