| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| New Member Join Date: Jun 2005
Posts: 18
![]() | Ajax, regexp, and url 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. ????: NamePros.com http://www.namepros.com/programming/178105-ajax-regexp-and-url.html 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. |
| |
| | #2 (permalink) |
| NamePros Member Join Date: Oct 2005
Posts: 27
![]() | 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"); ????: NamePros.com http://www.namepros.com/showthread.php?t=178105 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! |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |