Hi,
I am new to the forum and also fairly new to using javascript.
I am currently working on a website which I plan to make as dynamic as possible. I want to keep the function of the back button in the browser and allow bookmarking of sections etc. So I am using html anchors and javascript to refresh the page content in divs.
can I write a general function which will allow me to pass variables or post variables to a php script to generate the new content and change hash?
when I have a login form like
how would I allow user to click a button and have a javascript function handle everything.HTML Code:Username : <input type='text' name='uname' /><br> Password : <input type='password' name='password' />
I can do this no problem when there is no variables just don't know how to include variables in it.
currently for sections with no variables I do :
HTML Code:<li id="home"><a href="#home"><img src="css/images/home.jpg" alt="Home" /></a></li>Code:$().ready(function(){ setInterval("checkAnchor()", 300); }); var currentAnchor = null; //Function which chek if there are anchor changes, if there are, sends the ajax petition function checkAnchor(){ //Check if it has changes if(currentAnchor != document.location.hash){ currentAnchor = document.location.hash; //if there is not anchor, the loads the default section if(!currentAnchor) query = "section=homepage"; else { //Creates the string callback. This converts the url URL/#main&id=2 in URL/?section=main&id=2 var splits = currentAnchor.substring(1).split('&'); //Get the section var section = splits[0]; delete splits[0]; //Create the params string var params = splits.join('&'); var query = "section=" + section + params; } //Send the petition $.get("callbacks.php",query, function(data){ $("#content").html(data); }); } }
Thanks in advance![]()


Reply With Quote
Bookmarks