jQuery get request against Sinatra does not get text
Posted
by jerhinesmith
on Stack Overflow
See other posts from Stack Overflow
or by jerhinesmith
Published on 2010-02-16T19:03:02Z
Indexed on
2010/03/20
17:41 UTC
Read the original article
Hit count: 211
I have a very simple sinatra site that I'm trying to access via ajax through jQuery.
To keep things incredibly simple, this code snippet:
get '/behavior_count' do
"60"
end
which returns "60" in the browser, shows up as an empty string when attempting to access the site via $.get
in jQuery. The strange part is in Firebug, while the Response is empty, the HTTP header correctly describes Content-Length as 2, and I can see the request show up on the server.
Is there something specific to Sinatra that isn't returning my data, or am I not using jQuery correctly?
If it helps, I also tried this code:
get '/behavior_count' do
content_type 'text/plain', :charset => 'utf-8'
"60"
end
and my jQuery looks like
$.get('http://mysite:4567/behavior_count'); // Ignore the response, but
// watch the request in firebug
Any ideas?
© Stack Overflow or respective owner