ajax problems, history.js and chrome

40 views
Skip to first unread message

v.

unread,
Jan 25, 2019, 4:35:44 PM1/25/19
to Fat-Free Framework
Hi,

I am trying to wrap my head around this issue with ajax calls in combination with history.js.
I have this app that seems to work quite well in every browser except chrome.
I have a form that submits through ajax and gets a new form in return. This works well.

My routes show:
POST /process [ajax]=AjaxController->process
GET
|POST /start=PageController->start

The in-form back-button executes
onclick='javascript:History.back();e.preventDefault();'
The browser's back button shows the same functionality.

This works in every browser except chrome.
All browsers go back to the previous form items fine, except for chrome: it seems to do an actual non-ajax POST (if defined in the html form method) or GET request (otherwise) to the initial start page (start?postparam1=val&postparam2=val) which runs through my pagecontroller.

The funny thing is that sometimes it does work in chrome, but most of the time it doesn't.

I have no idea how to fix this or why this is happening.
If I run the relevant code in plain php it seems to work in chrome, so I am assuming it is a routing issue in f3?

ikkez

unread,
Jan 26, 2019, 5:31:37 AM1/26/19
to Fat-Free Framework
too many moving parts here to judge a part.. do you use history.pushState to populate a new state after you've submitted and preplaced the form (opened the next state)? adding new states (and having a proper history) is probably better than hijacking the history back function I guess.

v.

unread,
Jan 26, 2019, 7:30:12 AM1/26/19
to Fat-Free Framework
Hi Ikkez,
The next button does push a new state:
onclick='javascript:History.pushState({q:{{ @SESSION.q.step}}}, "q:{{ @SESSION.q.step}}", "?q={{ @SESSION.q.step}}");'>

what exactly do you mean by "hijacking the history back function"?

v.

unread,
Jan 26, 2019, 11:27:44 AM1/26/19
to Fat-Free Framework
So I spent my entire saturday afternoon working on this to find out it was a problem in my javascript code.
Very weird though, it only happened in chrome...

Sorry for posting this here.
Reply all
Reply to author
Forward
0 new messages