Welcome Guest, Not a member yet? Register   Sign In
reloading query data on redirect
#1

[eluser]kseize[/eluser]
I have a hockey scoring application wherein a page lists all the goals entered by the user so far. If they want to modify or delete the goal, it launches a form in an iframe in thickbox. On submit, the iframe/thickbox is close, the database is modified and I call a redirect (url helper) back to the page that lists all the goals.

Problem is: the redirect doesn't seem to be causing the controller to return updated values. I have to hit browser refresh to see updated values. I do not have any form of caching on.

Any ideas on how to force this?

BTW, first post here, and thanks to all who help out in these forums. It's been super helpful.
#2

[eluser]tonanbarbarian[/eluser]
What database are you connecting to i.e. mysql, oracle etc
If you are using a database that supports transactions (mysql innodb or oracle) then the problem might be that the transaction is not being written to the database before the redirect loads the new version of the page.

And since I have 0% experience with jquery or thickbox this might not be anyway thing... but if you are submitting something in the thickbox is thickbox doing the redirect or is CI. Because if it is thikcbox doing the redirect then I can sort of assume the following might be happening

1. fill in the form
2. click the "save" button or whatever in the thickbox
3. thickbox detects the form is "submitting" and closes (but without verifying that the form has finished submitting)
4. page refreshes

As you can see the timing may be such that the page is refreshing before the form submit has finished.
#3

[eluser]kseize[/eluser]
Yes, it is mySQL, and it a thickbox function in the html code that closes the iframe but it is a CI redirect. (The jquery function is attached to the onClick event on the form button.)

So the redirect code is definitely after the code that modifies the database, but does that make any difference. Maybe it is as you say that the transaction is slower than the redirect?
#4

[eluser]jcopling[/eluser]
If you can verify that the data is in fact being written to the DB it's just not displaying it upon return my thought would be tagging on a random string to the end of the url upon redirect.

So if your destination page is http://yourhost/controller/function

try making it something like

http://yourhost/controller/function?1Q2W3E4

The browser will acknowledge that it has not visited that page before and so it won't use any cache files.

It does uglify your URL string so if that's a problem then another solution may be in order.
#5

[eluser]kseize[/eluser]
Well, it appears that the redirect is not actually taking effect; that may explain the problem. Here is the controller code:

Code:
$this->load->helper('url');
$action = $this->input->post('action'); //Value of the submit button
        
        if ($action == "Cancel") {
        
                redirect('/results/editScoring/' . $gameID, 'refresh');
        
        }elseif($action == "Delete"){
        
                $this->results_model->delete_goal($gameID,$goalID);        
                redirect('/results/editScoring/' . $gameID, 'refresh');
                        
        }elseif($action == "Save"){

//END SNIPPET

For example, in the Delete section, the query gets triggered but not the redirect. Maybe because the page no longer exists to be redirected from ... since the iframe is killed from a function in the submit button onClick?

Code:
$js = 'onClick="self.parent.tb_remove()"';
echo form_submit('action', 'Save', $js) . form_submit('action', 'Cancel', $js) . form_submit('action', 'Delete', $js); ?>
</form>

Is there any parameter in refresh that can specify that the refresh should take place in the parent window?




Theme © iAndrew 2016 - Forum software by © MyBB