NameSilo

Ajax, regexp, and url

Spaceship Spaceship
Watch

Insenic

Established Member
Impact
0
To save myself time, I am going to copy this from anothor forum I posted on earlier, and have so far not been able to find a solution.

I am working out some base code for the recoding of a site. We have deicded we want to have an available AJAX interface for users.

Now let me just say I hate Javascript. Never really have liked it. But the web is evolving and so must I.

Now we all know a problem with AJAX is the broken back button, and bookmark failure (and dirrect linking). I have attempted te fix this with the url embeded tag id's Ex a url might resemble:

http://www.site.com/#/forums/topic/1
( note the site uses mod_rewrite)

Obviously their is no tag in the page with that id. Now here is my JS to handle that urls upon loading:


var searchAddr = new RegExp(".#/(\w+/)+(\.html)?");

// Test if they want a certain page. The URL would be formed like so: http://www.mustywind..com/#/forums/topic/1

if ( searchAddr.test( window.location.href ) ) {

var start = searchAddr.lastIndex + 1; // + 1 to get rid of the pound (#) character.
var end = window.location.href.strlen() - start;

callServer(window.location.substr(start, end), 'content', false); // custom function for ajax.
}


The custom function I have there is not important. What is importang as the rest of the code, and the first paramater in that function, which is the page to load from the server.

However when I load up a page in the format of the one above, it does not work. Like I said. I hate Javascript. Not really by thing.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
.US domains.US domains
I'm not sure what callServer() does, but it looks like you're trying to send a JavaScript redirect callback to the server as the script file name??? Try sending it as plain text...like
Code:
callServer("MyScript.php (replace w/ ur js string var holding the file name)", "ab=12&cd=3948", "mycustomjs");

That aught to call MyScript.php and pass in the ab and cd querystring...then when the MyScript.php is done, it'll call the mycustomjs function.

This is all based on the assumption that your callServer works like my makeRequest...look at the ComingSoon.asp on www.fun2pic.com on line 109.
And the /Includes/ajax.js for the function details.

...the passing of the querystring is also nasty, so you have to watch that...especially foobar for international characters...omg don't get me started on that carp!
 
0
•••
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99
Appraise.net

We're social

Unstoppable Domains
Domain Recover
NameMaxi - Your Domain Has Buyers
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back