This topic is locked
[SOLVED]

 Save and Redirect button works in Safari but not other browsers

8/18/2012 3:10:10 PM
PHPRunner General questions
P
Pauldee author

Hi All
I am having a problem with browser compatibility.
I have created a button on a page and the intention for the button was to Save the record then redirect to a specific page. (I don't want to use the Event 'After record added' as I want to add a number of buttons to go to various pages).
On the Buttons 'Client After' event I use the following code:



var save_button = $("a[id^='saveButton']");

save_button.click();


Then on the Buttons 'Server' event I have the redirect:



header ( "http://nameofpage.php";);


The above works as expected in Safari

Only saves the record in IE

And only redirects in Firefox!
I cannot dictate what browser the project is going to be used in so any workaround would be very much appreciated.
Regards

Paul

C
cgphp 8/19/2012

"Server" is an ajax response and header will not work properly. Execute redirection in the "Client after" tab.

Sergey Kornilov admin 8/19/2012

Crustian is 100% right, you need to use ClientAfter event to perform redirects. Here is an example:

window.location = "http://www.google.com/";;
P
Pauldee author 8/20/2012

Thank you both for your time. All working!
I also moved the code to save the record to 'Client Before' and all works as required.
Paul