In my rails application(rails 2.3.4 and ruby 1.8.7) When i click on News , an ajax call is made and data is loaded.
<a href="News" onclick="load_feed();"><u>Show More...</u></a>
<script>
function load_feed()
{
$.ajax({
url: this.url,
dataType: 'script'
})
$('div .rss_feed_1').append("<%= escape_javascript(render :partial => "news_feed_data") %>");
}
</script>
When i click an ajax call is made and data is loaded. but the url changes to
开发者_Go百科http://localhost:3000/us/dropbox#News from http://localhost:3000/us/dropbox , Is there any way out that i can get this url http://localhost:3000/us/dropbox/News by removing the #.
Using the new Javascript pushState you can create pretty looking URL:s while staying on the same page and only using AJAX for data fetching.
Here is an example of it. This is also the method Facebook uses.
You just have to put 'return false;' at the end of your function or write 'onclick="load_feed(); return false;"'. So you prevent that the default action (following the link) will be triggered.
精彩评论