Menu DEVPPL Search
157.709
MEMBERS
15.939
TOPICS
63.213
POSTS
  562
FLASH GAMES
7.718
TUTORIALS
 

Login

E-mail:
Password:

How to refresh just one side of the page

0

Loading

How to refresh just one side of the page

Postby Maureen Moore » Wed Dec 26, 2012 6:01 pm

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.
Maureen Moore
 
Reputation: 2
Posts: 40
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

Login to get rid of ads

 

goldmedal
2

Loading

How to refresh just one side of the page

Postby Mark Spend » Tue Feb 12, 2013 11:33 am

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: 2
Posts: 2
Joined: Mon Feb 11, 2013 10:47 am
Highscores: 0
Arcade winning challenges: 0
0

Loading

Re: How to refresh just one side of the page

Postby Rasmus Lindström » Thu Dec 27, 2012 9:10 am

I suggest that you use PHP sessions for 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: 2794
Joined: Tue Aug 17, 2004 2:07 pm
Location: Sweden
Highscores: 1
Arcade winning challenges: 0
0

Loading

Re: How to refresh just one side of the page

Postby Maureen Moore » Thu Dec 27, 2012 6:53 pm

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: 40
Joined: Mon Nov 19, 2012 2:23 pm
Highscores: 0
Arcade winning challenges: 0
0

Loading

Re: How to refresh just one side of the page

Postby Maureen Moore » Fri Dec 28, 2012 10:02 pm

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
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: 40
Joined: Mon Nov 19, 2012 2:23 pm
Highscores: 0
Arcade winning challenges: 0
0

Loading

Re: How to refresh just one side of the page

Postby Rasmus Lindström » Sat Dec 29, 2012 8:18 am

I don't know anything about CakePHP, but I know PHP and jQuery.

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: 2794
Joined: Tue Aug 17, 2004 2:07 pm
Location: Sweden
Highscores: 1
Arcade winning challenges: 0
0

Loading

Re: How to refresh just one side of the page

Postby Maureen Moore » Sat Dec 29, 2012 3:22 pm

Thanks I just need to put that in ajax.ctp instead of the php file.
Maureen Moore
 
Reputation: 2
Posts: 40
Joined: Mon Nov 19, 2012 2:23 pm
Highscores: 0
Arcade winning challenges: 0
0

Loading

Re: How to refresh just one side of the page

Postby Maureen Moore » Sat Dec 29, 2012 3:53 pm

I can get the draggable meal tiles with ajax now but they're no longer draggable.
Maureen Moore
 
Reputation: 2
Posts: 40
Joined: Mon Nov 19, 2012 2:23 pm
Highscores: 0
Arcade winning challenges: 0
0

Loading

Re: How to refresh just one side of the page

Postby Maureen Moore » Sat Dec 29, 2012 3:54 pm

The draggable meal tiles aren't in the view source now.
Maureen Moore
 
Reputation: 2
Posts: 40
Joined: Mon Nov 19, 2012 2:23 pm
Highscores: 0
Arcade winning challenges: 0
0

Loading

Re: How to refresh just one side of the page

Postby Maureen Moore » Sat Dec 29, 2012 8:38 pm

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: 40
Joined: Mon Nov 19, 2012 2:23 pm
Highscores: 0
Arcade winning challenges: 0
0

Loading

Re: How to refresh just one side of the page

Postby Maureen Moore » Sun Dec 30, 2012 5:07 pm

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: 40
Joined: Mon Nov 19, 2012 2:23 pm
Highscores: 0
Arcade winning challenges: 0
Next
^ Back to Top