Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7995119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:19:02+00:00 2026-06-04T14:19:02+00:00

Before Anything: $.getJSON back button showing JSON return data not the page did not

  • 0

Before Anything: $.getJSON back button showing JSON return data not the page did not help, as well as https://groups.google.com/group/angular/browse_thread/thread/3787ad609c0beb77/eb1b57069dab9f63 did not and the internet too did not help.

Here’s the issue:

I’m calling an url from within a page to get json data, which then gets rendered with jquery templating inside this same page.

Imagine we’re on the page http://someurl.com/search and we’re starting a request like this

$.ajax({
  url: '/searchthis', //important, this is NOT THE SAME URL
  cache: false,
  type: 'GET',
  headers: {
    "Accept": "application/json",
  },
  dataType: 'json'
  success: function(data) {
    doSomethingWithResults(data);
  }
});

The Rack response has the cache control header set to no cache:

Cache-Control:no-cache

Everything works fine, but if you leave the page for another page in Chrome and then press the back button, you will get shown naked JSON Data. The same behaviour is there when you hit the reload Button in IE8. Both work perfectly fine if you just press Enter on the url in the adress bar.

I’m not getting how I could fix this, because the Chrome guys won’t do it (see http://code.google.com/p/chromium/issues/detail?id=108425)

It seems to me like misinterpretation on the browsers side, because it caches something it really should not (response Header) and it caches something under a wrong url (because the JSON request does not hit the same URL)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T14:19:04+00:00Added an answer on June 4, 2026 at 2:19 pm

    The problem was actually Rails: Both Chrome and IE request the last response with no specific format, so Rails just takes the first response block, which happened to be json in my case. Putting the html block in front of the json block solved the issue.

    respond_to do |format|
      format.html { ... } //important because the request comes with no specific format
      format.json { ... }
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to force my page to load all data before anything is
Before anything, I am not looking for a re-write. This was presented to me,
Is there anything special I have to do to a JSON object before I
Before anything, this is not necessarily a question.. But I really want to know
Is it possible to have Greasemonkey scripts run before anything else on the page?
I have sanitize class that I run before anything else on every page of
Before anything else, here is the simplified schema ( with dummy records ) of
Error that pops up even before anything else loads: Package Load Failure Package 'Microsoft.TeamFoundation.Client.ServicesHostPackage,
I want to write a custom validator which doesn't do anything before the user
I need to convert a string to another which has removed anything before the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.