Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sinatra app #36

Closed
Nerian opened this issue Jun 29, 2011 · 1 comment
Closed

Sinatra app #36

Nerian opened this issue Jun 29, 2011 · 1 comment

Comments

@Nerian
Copy link

Nerian commented Jun 29, 2011

I am using Sinatra and want to use Pjax but for some reason that I don't understand it is not working.

App:

get '/docs/*' do                                           
  if request.xhr?
    puts "Sending a pjax request"  
    puts "docs/#{params[:splat].join('/')}.html"
    haml :"docs/#{params[:splat].join('/')}.html", :layout => false
  else
    haml :"docs/#{params[:splat].join('/')}.html", :layout => :'docs_layout'
  end  
end      

Log:

Sending a pjax request
docs/introduction.html
127.0.0.1 - - [29/Jun/2011 19:37:24] "GET /docs/introduction?_pjax=true HTTP/1.1" 200 1636 0.2096
[2011-06-29 19:37:24] ERROR Errno::ECONNRESET: Connection reset by peer
    /Users/Nerian/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/httpserver.rb:56:in `eof?'
    /Users/Nerian/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/httpserver.rb:56:in `run'
    /Users/Nerian/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
127.0.0.1 - - [29/Jun/2011 19:37:25] "GET /docs/introduction HTTP/1.1" 200 11345 0.1347

Javascript:

$(function() {  
    $('#index a').pjax('#doc')   
});                 

HTML

http://pastebin.com/uVXmBzL1

It seems that an ajax request is made but then something goes wrong and a non-ajax request is made, reloading the entire page. I am not sure where is the error.

I did a:

wget --header="X-Requested-With: XMLHttpRequest" http://localhost:3000/docs/validation?_pjax=true

And it gave me the right page, without layout. Maybe the problem is in the client side? But then, why the

ERROR Errno::ECONNRESET

In the server log?

I hope you can point me in the right direction :)
Thanks

@Nerian
Copy link
Author

Nerian commented Jun 29, 2011

Solved:

After a couple of hours I remembered that I was using Shotgun to reload the app on each request. That broke pjax.

@Nerian Nerian closed this as completed Jun 29, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant