Hi all, I've been tweaking a jquery script for a while and everything was great until a few hours ago. I have very basic knowledge when it comes to ajax and I can't figure this out by myself so hopefully someone can help me out..
jquery/ajax issue, need help
5
Hi all,
I've been tweaking a jquery script for a while and everything was great until a few hours ago. I have very basic knowledge when it comes to ajax and I can't figure this out by myself so hopefully someone can help me out..
I have a main index.php file that contains <li> elements inside, each <li> represents a part of the website (using ajax) like this:
I wanted to load each <li> dynamically and divide my website into folders to make it search engine friendly ... which I did and this is my code to load content dynamically:
dlist.php is a script that displays a list of the folders i have in my main root like this:
each id represents an existing folder e.g. domain.com/about/ , that is what dlist.php does, it turns the name of each root folder into a <li id='NAME_OF_THE_FOLDER' class='load'></li>
each of those folders has its own index.php file with a div element which ID is #loadContent (thats the part i want to load inside each li element)
so my jquery code turns this
into this
and it loads each #loadContent from each folder inside the <li> elements with a 'load' class
to access each section I use hash tags like this: domain.com/#about (that only shows the 'about' <li> element)
ok so that is working fine BUT the problem is I can only see my website once, every time I try to access it again (without clearing the browser cache) it won't look good, I don't understand why it only looks good once, is there something wrong with my little piece of code?
sorry that i can't give a link but I don't have a hosting for it yet, I've been testing it offline with xampp (to test php websites offline)
I read earlier that it may be due to the browser caching my website, but tried every solution to disable cache and it still won't work
Advice please? I need help on this one!
-sp
I've been tweaking a jquery script for a while and everything was great until a few hours ago. I have very basic knowledge when it comes to ajax and I can't figure this out by myself so hopefully someone can help me out..
I have a main index.php file that contains <li> elements inside, each <li> represents a part of the website (using ajax) like this:
HTML Code:
<ul id='dList'> <li id='home'> content </li> </ul>
Code:
$(document).ready(function() { $.get('bin/dlist.php', function(dList) { $('#dList').append(dList); $('.load').each(function() { $(this).load($(this).attr('id') + '/index.php #loadContent'); }) }); });
PHP Code:
<li id='about' class='load'></li>
<li id='products' class='load'></li>
<li id='contact' class='load'></li>
each of those folders has its own index.php file with a div element which ID is #loadContent (thats the part i want to load inside each li element)
so my jquery code turns this
HTML Code:
<ul id='dList'> <li id='home'> content </li> </ul>
HTML Code:
<ul id='dList'> <li id='home'> content </li> <li id='about' class='load'> #loadContent </li> <li id='products' class='load'> #loadContent </li> <li id='contact' class='load'> #loadContent </li> </ul>
to access each section I use hash tags like this: domain.com/#about (that only shows the 'about' <li> element)
ok so that is working fine BUT the problem is I can only see my website once, every time I try to access it again (without clearing the browser cache) it won't look good, I don't understand why it only looks good once, is there something wrong with my little piece of code?
sorry that i can't give a link but I don't have a hosting for it yet, I've been testing it offline with xampp (to test php websites offline)
I read earlier that it may be due to the browser caching my website, but tried every solution to disable cache and it still won't work
Advice please? I need help on this one!
-sp
- eswariseo
- iaeo
- [1] reply
- espe
- [1] reply
Next Topics on Trending Feed
-
5