ruby - Sinatra does nothing with requests from a phonegap application -


i have simple sinatra server post block. if send $.post browser server receives post, when sent phonegap application nothing, no error code or output whatsoever.

i wrote simple tcpserver#accept process, , since successful proceeded sinatra, found following:

this post works in sinatra , tcpserver.accept

post /api/v/1 http/1.1 host: localho.st:8015 content-type: application/x-www-form-urlencoded; charset=utf-8 origin: http://api.jquery.com cookie: _fitter_session=[deleted] content-length: 7 connection: keep-alive accept: */* user-agent: mozilla/5.0 (macintosh; intel mac os x 10_10_5) applewebkit/601.5.17 (khtml, gecko) version/9.1 safari/601.5.17 referer: http://api.jquery.com/jquery.post/ accept-language: en-us accept-encoding: gzip, deflate 

the next 1 doesn't work in sinatra though still in tcpserver

post /api/v/1 http/1.1 host: localho.st:8015 connection: keep-alive content-length: 362 accept: application/json, text/javascript, */*; q=0.01 origin: file:// user-agent: mozilla/5.0 (linux; android 4.4.2; sm-g900f build/kot49h) applewebkit/537.36 (khtml, gecko) version/4.0 chrome/30.0.0.0 safari/537.36 content-type: application/x-www-form-urlencoded; charset=utf-8 accept-encoding: gzip,deflate accept-language: en-us cookie: _fitter_session=[deleted] x-requested-with: com.myapp.myphonegapp 

i think missing obvious can't find is, i'm searching in google find no soluction or similar problem, welcome

thanks in advance.

edit: - tried running rails server , receives post correctly. - problem affects both , post sent phonegap application.

edit2:

sinatra file:

require 'sinatra' # require 'sinatra/cross_origin'  set :port, 8015 #set :server, 'thin'  post '/api/v/1'   puts 'it worked!' end 

phonegap ajax request:

$.post('http://localho.st:8015/api/v/1', {         test: 'foo'       })         .done(function(s) {           console.log(s);         })         .fail(function(e) {           console.log(e);         }) 

if run node server , serve application request runs succesfully (with cors enabled in browser) on android device, doesn't, again, if replace sinatra rails in same port, rails gets request

try put in codeset :bind, '0.0.0.0'. guess server listening on localhost.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -