I want to send message m
and data v
to the server, and do not need to do anything particularly with the response on the client Javascript. Is there a request method for doing this? If not, I want to return a minimally acceptable string to the client (which will not be processed). What is the best way to do this?
I tried doing this on the Javascript,
function report(m,v){
io=new XMLHttpRequest();
io.open("POST","http://localhost:3000?m="+m,true);
io.send(JSON.stringify(v));
return false;
};
and as a response to it, I sent what I think is a minimum serialized string created by Ruby like
[].to_json
And the client Javascript says the server responded with a status of 500 (Internal State Error)
.
Edit
On the server side, I have a Ruby code like this:
Rack::Handler::Thin.run(Rack::Builder.new do
map("/") do
run(->env{[200, {}, [server.ajax(
Rack::Utils.parse_nested_query(env["QUERY_STRING"]),
env["rack.input"].read
)]]})
end
end, Port: 3000)
where server.ajax
method is like this:
def ajax h, v
m, v = h["m"].to_sym, JSON.parse(v)
case m
...
when :error
puts m
p v
return "" # or `[].to_json` or whatever
...
end
end
and in the particular case, I have the message m
which is 'error'
. And I get output from the code above, so I think the problem is with the response.