AJAX bookmarking/forward/back

igames

New Member
Messages
34
Reaction score
0
Points
0
Hey people of x10!

I am currently building a AJAX based site and i have found many tutorials and links to make the forward/back buttons work along with bookmarking, but i havent been able to get any of them to work.

If anyone here could help me out with this i would be very happy and grateful. If you would like to see what i have right now you can check it out at http://www.playminigames.co.cc/test/index.php

Thanks!
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
This isn't what you're looking for, but are you sure that site should be using AJAX the way it does? Your site isn't application-y, it's web page-y, which suggests AJAX is not the best thing for your site. Read over:
You might also want to take a peak at other, similar pages on when to use AJAX.

Edit:
Two problems with the page: the fragment identifiers (eg "#Games") are capitalized, so the AJAX requests are for non-existant pages (URIs are case sensitive; "/Games.php" is different from "/games.php"). The second problem is that the response text is a complete HTML document. You need a document fragment, not a document, to insert into the page.
 
Last edited:

nirajkum

New Member
Messages
159
Reaction score
0
Points
0
are you trying to make some some bookmarking social networking site . If yes there are already lots of free CMS available which do the same thing . Just download and configure it
 

igames

New Member
Messages
34
Reaction score
0
Points
0
no im just trying to get the forward, back, and bookmark working, because i found out that everything loads 5 seconds faster when you dont have to load the ad every time, so do you have any suggestions on scripts that i can use?
 

xav0989

Community Public Relation
Community Support
Messages
4,467
Reaction score
95
Points
0
For the bookmarking functionnality, it's not even AJAX, it's simple Javascript. Here, the first link I found searching on google.

Next for your previous/next buttons, could you explain in detail what do you mean. As well, could you specify what were you able to do with those up to now?

Finally, I would recommend that each time you click on a link, you would change or create a fragment identifier in the url, so that users can sort-of know where they are on your site (the #section part in the URL).
 
Last edited:

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Another problem is that the script that loads content based on the fragment identifier:
Code:
if ((window.location.href.split("#", 2)[1] == null) 
 || (window.location.href.split("#", 2)[1] == "") 
 || (window.location.href.split("#", 2)[1] == "index"))
{
    sendRequest("../index2.php");
} else {
    [COLOR="Red"]sendRequest(window.location.href.split("#", 2)[1] + ".php");[/COLOR]
}
loads a relative URL, which means (eg) http://www.playminigames.co.cc/test/index.php#games tries to load http://www.playminigames.co.cc/test/games.php, which doesn't exist.

Performance note: the 4 identical calls to split is wasteful. You could use a variable, a switch or drop the call entirely because the Location object has a 'hash' property that holds the fragment identifier, including the '#':
Code:
switch (window.location.hash.toLowerCase()) {
case '':    // FALLTHRU
case '#':  // FALLTHRU
case '#index':
    sendRequest("../index2.php");
    break;

default:
    sendRequest([COLOR="Red"]'../' + [/COLOR] window.location.hash.substring(1) + ".php");
    break;
}

I'm a little concerned that your script is replacing its parent, which isn't fully defined. The technique works on Safari 4, but may not work on other browsers, as elements may not be added to the document until fully processed (i.e. the end tag is encountered).
 
Last edited:

igames

New Member
Messages
34
Reaction score
0
Points
0
xav0989 i mean so you can use the forward/back/bookmark in the web browser, not a button to do it, sorry for being unclear, and mission i am still working on your suggestion, ok so i transfered the test file to my main directory and you can look at it here, you can look at the source code at http://www.playminigames.co.cc/testindex.txt and i have my js file at http://www.playminigames.co.cc/ajax.js

could you please help me with this i am fairly new and when i click on "games" my normal url for it is /games.php so could you tell me whats wrong?
 
Last edited:

xav0989

Community Public Relation
Community Support
Messages
4,467
Reaction score
95
Points
0
By the way, looking at your source code, you should move the session_start() function to be the second function called, just after any header() function calls, if you have any.

Next, concerning the previous/next functionality, I would have recommended for the time being to create previous/next buttons in your app and specifying that your users use your previous/next buttons instead, but I found a great post on AOL that covers exactly what you are searching for.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
could you please help me with this i am fairly new and when i click on "games" my normal url for it is /games.php so could you tell me whats wrong?
The Really Simply History library that xav0989 linked to is a better solution (modulo the lack of Safari support), but if you want to know a fix for your code, take a closer look at my last post. Both my previous posts, actually, for the first describes another serious bug that still needs to be fixed.
 

xav0989

Community Public Relation
Community Support
Messages
4,467
Reaction score
95
Points
0
The Really Simply History library that xav0989 linked to is a better solution (modulo the lack of Safari support), but if you want to know a fix for your code, take a closer look at my last post. Both my previous posts, actually, for the first describes another serious bug that still needs to be fixed.
Correcting the bug in the oldest post will require redesigning the main page. Instead of loading a whole page in a iframe, you should load a page fragment (the content of the page) in a div.
 
Top