willsc8forwings Posted March 24, 2007 Share Posted March 24, 2007 Well I'm looking for a ajax code just when u click on a link, something on the page will change. I did read the tutorial, but what i need is one half of the page to come up without any loading. Link to comment Share on other sites More sharing options...
willsc8forwings Posted March 24, 2007 Author Share Posted March 24, 2007 edited the question, sorry. Link to comment Share on other sites More sharing options...
jesh Posted March 26, 2007 Share Posted March 26, 2007 If you want to change the content on a portion of a page without reloading the entire page, you can set the innerHTML property of a div element.Here's an example that changes the innerHTML of a div when you click on a button. If you get the new content from an AJAX request, you can use the responseText property of that AJAX request as the text to display in that div: <html><head><script>function update(){ // first, get a reference to that div element var div = document.getElementById("UpdateDiv"); // next, set the innerHTML property of that div to display // the new content. div.innerHTML = "This is some new content."; // If you had an AJAX request called xmlHTTP, you could set // the innerHTML like this: // div.innerHTML = xmlHTTP.responseText; // Just hiding the button...no particular reason. document.getElementById("ChangeButton").style.display = "none";}</script></head><body><div>This is some static content.</div><div id="UpdateDiv">This content will change</div><button id="ChangeButton" onclick="update();">Update</button></body></html> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now