in Ruby on Rails routing, can it be www.example.com/ ... #! ... always go to controller => 'redirect'?
In Ruby on Rails routing (using route.rb), can it say, for any URL having the form:
www.example.com/ ... #! ...
t开发者_JAVA百科hen use controller redirect
?
This is so that in AJAX, some page can tag the #!
at the end of URL so that the real content of interest is the part after the #!
You seem to be wanting to do something like what facebook does, yes?
Well, then, you need to think about what is done in ajax on the browser, and what is done on the server, and what the browser sends to the server. Specifically, you should be aware of this:
The browser never sends to the server anything after the #
sign.
Therefore, if the url is http://mysite.com/foo/bar#!/baz
, all the broser sends to the server is http://mysite.com/foo/bar
. So your question, which is about server-side processing, doesn't really make sense because the web application on the server side doesn't see that.
What you need is some browser-side javascript to take a url that ends in #!
and make an XMLHttpRequest
to the server for something like http://mysite.com/content_js/bar
, which could then return the inner piece of content, without all your headers, footers, and sidebars, wrapped in some sort of json object. The browser-side javascript could then render that content.
精彩评论