Yii Framework Forum

Unexpected click event on page refresh


(Biz) #1

Hi,

There are on the page:

  1. Pjax around GridView
  2. Add button (creates new record via GET AJAX and refreshes Pjax)
  3. Delete button (deletes selected records via POST AJAX and refreshes Pjax)
    The code is obvious for every action.

The problem is with Safari 12.0 after page refreshed time to time (without any system) fires onclick event for the button, so new record adding!!! The problem appears after Pjax refreshed and page refreshed manually. It seems to be only on Safari the other browsers do not produce the problem.
The buttons are before and outside of Pjax and GridView in separate div.

What could it be?
Thank you for any opinion.

After some checking I have discovered that Safari makes hidden cached get request used some time before, not click event.


(Biz) #2

Solved by setting AJAX cache to false!

Before:

$.get(url,{data : data})

After:

$.get({url, cache: false},{data : data})