jsFiddle doesn't let you connect to actual JSON data, does it? If
there is a way, I could give it a try. Otherwise, I figured this would
be a common problem with a standard solution. This app isn't using
routes. It's just a controller that pulls in a JSON resource. After
hitting back, the browser displays the json to the user.
angular.service 'DailyCount', ($resource) ->
$resource '/analytics/doc_totals/:doc_id?tz_offset=:tz_offset&start_date=:start_date&end_date=:end_date',
{}, get: { method: 'GET' }
And here is the code from the controller that gets the resource:
scope.daily_opens = {}
scope.load_daily_counts = (start_date='', end_date='') ->
DailyCount.get { doc_id: $routeParams.doc_id, start_date:
start_date, end_date: end_date, tz_offset: -1 * new
Date().getTimezoneOffset() }, (data) ->
scope.daily_opens = data.open_events
scope.graph.open_event_graph(scope)
scope.load_daily_counts()
Thank you, Vojta, for your reply.
I have discovered that this problem appears to be Chrome only. Firefox
and Safari do not exhibit this problem. Chrome exhibits it
consistently (I am running Chrome stable 16.0.912.63).
I have been attempting to debug this for some time, but cannot seem to
discover what is causing the problem. Another AngularJS page that
operates in much the same way does not exhibit this problem. (That
page does some things that this page does not, such as loading Google
Graphs...my initial post in this thread indicated that it was that
page which was exhibiting the problem, but I was mistaken...the
problematic page is much simpler...just a dynamic index of resources,
no graphs.)
I hope to be able to solve the problem and report back if I do, but at
this point, I need to move on.
Thank You,
Daniel
I'll need to make a boiled down example that reproduces the problem
(it's part of a large application). Let me see if I can do that and
get back to you.
Thank You,
Daniel
Hello Vojta,
I have successfully reproduced the problem, though I think the problem
is simply a bug in Chrome.
The problem arises when the same url is used to generate both the html
and the json. For example:
i. I navigate to http://localhost/docs
ii. my browser requests html
iii. the page is rendered
iv. upon rendering, javascript in the page requests the list of docs
from the same url, but this time the content type is json
v. Chrome appears to view the most recent response as the source for
http://localhost/docs, even though it is json: viewing page source,
navigating away and then hitting back, both show the json, rather than
the html
A minimal example that reproduces this behavior is available from
https://github.com/dnelson-cs/chrome_json_bug
Thank You,
Daniel
I boiled it down even further to a very minimal case (without
AngularJS) and opened a Chrome bug:
http://code.google.com/p/chromium/issues/detail?id=108766
-Daniel
--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/angular?hl=en.
Using the same URL is proper RESTful practice, and is encouraged by
web application frameworks such as Ruby on Rails. A URL indicates a
single resource; the HTTP method (GET, POST, PUT, DELETE) indicates
what should happen on that resource; and the ACCEPT header indicates
the format that the resource should be presented in.
It is not the expected behavior for an end user to be looking at a
nicely styled web page, to navigate elsewhere, and then, after hitting
the back button, to see naked JSON. The other browsers respond in the
expected manner. Chrome does not.