I have navigation menu when clicked only a content div in the page should be updated from html contect files that in the server withouod doing a full page refresh, how can i achieve this using jquery?
+1
A:
create a div element and update the contents.
<div id="refreshblock"> </div>
assume that this is the block
on the button click , make a ajax call and get the results once you get the results process them and update the above div
('#refreshoblock).html(results);
It will update the page without doing a post back
gov
2010-10-23 05:13:15
+1
A:
You need to use the jQuery AJAX methods to accomplish this. There are several ways to go about it. For instance:
Say you have a div with id="mydiv" that you wish update with content from the server. Then:
$("#mydiv").load("url");
will cause mydiv to be updated with the content returned from url.
This link describes various AJAX methods in jQuery.
Vincent Ramdhanie
2010-10-23 05:14:05
+2
A:
Build your menu as per usual, i.e.
<ul id="menu">
<li><a href="about-us.html">About Us</a>
<li><a href="services.html">Services</a>
<li><a href="products.html">Products</a>
</ul>
And a placeholder for the content.
<div id="content"></div>
Then run code similar to this
$("#menu li a").click(function(e) {
// prevent from going to the page
e.preventDefault();
// get the href
var href = $(this).attr("href");
$("#content").load(href, function() {
// do something after content has been loaded
});
});
Marko
2010-10-23 05:17:26
+1
A:
$('#myLink').click(function(){
$.get('url.php', function(data){ // or load can be used too
$('#mydiv').html(data);
});
});
polyhedron
2010-10-23 05:18:03
marko's got the most complete answer
polyhedron
2010-10-23 05:19:12
Great,Thanks all....
DSharper
2010-10-23 07:50:36