| You are here: DEVPPL ‹ Forum ‹ Programming ‹ PHP and MySQL Forum |
NOTIFICATIONS
|
|
|||||||||||||||
Login |
How to refresh just one side of the page
18 posts
• Page 1 of 2 • 1, 2
0
How to refresh just one side of the page
See http://myownmealplanner.com/mealplans/add/5 for the example
If you drag a meal tile to the right side of the page then it should stay there after you click on <a href="/mealplans/add">Go back to list of meal tiles</a> but of course it doesn't because the entire page gets refreshed. I tried adding an anchor for just the mealplan tiles (like a back to top button) but still the entire page gets refreshed. I can't think of any way to do this with jquery, javascript or php. Any ideas? You're supposed to be able to add tiles from the 500 calorie list and then for example the 300 cal list. Right now I only have 500 calorie tiles but you can see how it's supposed to work. This was made with the cakephp framework but the principles are the same as for a normal website.
If you drag a meal tile to the right side of the page then it should stay there after you click on <a href="/mealplans/add">Go back to list of meal tiles</a> but of course it doesn't because the entire page gets refreshed. I tried adding an anchor for just the mealplan tiles (like a back to top button) but still the entire page gets refreshed. I can't think of any way to do this with jquery, javascript or php. Any ideas? You're supposed to be able to add tiles from the 500 calorie list and then for example the 300 cal list. Right now I only have 500 calorie tiles but you can see how it's supposed to work. This was made with the cakephp framework but the principles are the same as for a normal website.
- Maureen Moore
- Reputation: 2
- Posts: 32
- Joined: Mon Nov 19, 2012 2:23 pm
- Highscores: 0
- Arcade winning challenges: 0
How to refresh just one side of the page - Sponsored results
- Sponsored results
1
How to refresh just one side of the page
I've a simple solution for this issue, if you are working on a a server side language like php, you can easily pass the form page url to the processing page in different hidden variable, and you can operate that in the form processing page to redirect the process back.
- Mark Spend
- Reputation: 1
- Posts: 2
- Joined: Mon Feb 11, 2013 10:47 am
- Highscores: 0
- Arcade winning challenges: 0
0
Re: How to refresh just one side of the page
I suggest that you use PHP sessions for this.
On the top of all pages, add:
Then instead of setting a variable like:
You do it like this:
Then on any other page, you can use these variables like this:
On the top of all pages, add:
php code
<?php
session_start();
?>
Then instead of setting a variable like:
php code
$var = "hello";
You do it like this:
php code
$_SESSION['var'] = "hello";
Then on any other page, you can use these variables like this:
php code
echo $_SESSION['var'] // will print out: hello
or a more basic way:
$var = $_SESSION['var'];
echo $var;
- Rasmus Lindström
- Site Admin
- Reputation: 18
- Posts: 2830
- Joined: Tue Aug 17, 2004 2:07 pm
- Location: Sweden
- Highscores: 1
- Arcade winning challenges: 0
0
Re: How to refresh just one side of the page
Thank you. Maybe I'll try it that way. I'm not ready to work on it yet. I'm procrastinating because it gets complicated with cakephp sessions.
- Maureen Moore
- Reputation: 2
- Posts: 32
- Joined: Mon Nov 19, 2012 2:23 pm
- Highscores: 0
- Arcade winning challenges: 0
0
Re: How to refresh just one side of the page
I don't need sessions after all. I want to use ajax with load. If you start with http://myownmealplanner.com/mealplans/add/5 and click on the "100 cal tiles" div you get the ajax message "Request successful
MEAL TILES" because of
The problem with Cakephp though is that it seems to have only one ajax.ctp file for all of the loads so I can't make 8 separate messages, one for each tile collection. How do I load for example the CTP called test without using the same ajax.ctp file as for the other ones? I need a separate ajax.ctp for every callback.
MEAL TILES" because of
- Code: Select all
<div id="clickMe">100 cal tiles</div>
<div id="result"></div>
<script type="text/javascript">
$("#clickMe").click(function() {
$('#result').load('test');
});
</script>
The problem with Cakephp though is that it seems to have only one ajax.ctp file for all of the loads so I can't make 8 separate messages, one for each tile collection. How do I load for example the CTP called test without using the same ajax.ctp file as for the other ones? I need a separate ajax.ctp for every callback.
- Maureen Moore
- Reputation: 2
- Posts: 32
- Joined: Mon Nov 19, 2012 2:23 pm
- Highscores: 0
- Arcade winning challenges: 0
0
Re: How to refresh just one side of the page
I don't know anything about CakePHP, but I know PHP and jQuery.
How about using a GET-variable within the load.
You can then grab the 'foo'-variable in the PHP file that you requests from and print out different meals depending on the variable.
file.php:
How about using a GET-variable within the load.
html code
.load('file.php?foo=200');
You can then grab the 'foo'-variable in the PHP file that you requests from and print out different meals depending on the variable.
file.php:
php code
<?php
$foo = $_GET['foo'];
if ($foo == 100) {
echo "Print info on 100";
}
if ($foo == 200) {
echo "Print info on 200";
}
?>
- Rasmus Lindström
- Site Admin
- Reputation: 18
- Posts: 2830
- Joined: Tue Aug 17, 2004 2:07 pm
- Location: Sweden
- Highscores: 1
- Arcade winning challenges: 0
0
Re: How to refresh just one side of the page
Thanks I just need to put that in ajax.ctp instead of the php file.
- Maureen Moore
- Reputation: 2
- Posts: 32
- Joined: Mon Nov 19, 2012 2:23 pm
- Highscores: 0
- Arcade winning challenges: 0
0
Re: How to refresh just one side of the page
I can get the draggable meal tiles with ajax now but they're no longer draggable.
- Maureen Moore
- Reputation: 2
- Posts: 32
- Joined: Mon Nov 19, 2012 2:23 pm
- Highscores: 0
- Arcade winning challenges: 0
0
Re: How to refresh just one side of the page
The draggable meal tiles aren't in the view source now.
- Maureen Moore
- Reputation: 2
- Posts: 32
- Joined: Mon Nov 19, 2012 2:23 pm
- Highscores: 0
- Arcade winning challenges: 0
0
Re: How to refresh just one side of the page
I was thinking maybe if I loaded an XML file with ajax I might be able to see it in view source but now I keep getting the error "failed to load external entity tiles.xml" Should I keep trying to create draggable divs with xml or am I on the wrong path here anyway?
- Maureen Moore
- Reputation: 2
- Posts: 32
- Joined: Mon Nov 19, 2012 2:23 pm
- Highscores: 0
- Arcade winning challenges: 0
0
Re: How to refresh just one side of the page
I got it to load the XML file but the XML doesn't show up in View Source either so I won't be able to use it.
- Maureen Moore
- Reputation: 2
- Posts: 32
- Joined: Mon Nov 19, 2012 2:23 pm
- Highscores: 0
- Arcade winning challenges: 0
|
|