pengu Posted September 6, 2011 Share Posted September 6, 2011 First off, I hope I've posted this in the correct spot. Apologies if I have not. All I want is a couple of links, lets say 1 2 and 3, they're all href links that lead to some page, but they have an "id" within the HREF. So when I click them, I want them to load the results into a div, not just load another page. What I have so far.. <!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript"> $("#spLink").click(function(){ $("#spResult").html(ajax_load).load(); }); </script> </head> <body> <h1>Test</h1> <p><a href="test.html" id="spLink">Click</a></p> <p><a href="test2.html" id="spLink">Click</a></p> <p><a href="test3.html" id="spLink">Click</a></p> <div id="spResult"> </div> </body> </html> Help! Quote Link to comment https://forums.phpfreaks.com/topic/246517-jquery-ajax-href-links/ Share on other sites More sharing options...
pengu Posted September 6, 2011 Author Share Posted September 6, 2011 Amazing, thought someone would respond by now. Anyways, I've got this far (see code). But it's not loading my pages into the DIV. Works firefox. No go Chrome. <!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript"> $(document).ready(function() { $('.spLink').click(function(e) { e.preventDefault(); var href = $(this).attr('href'); $('.spResult').load(href); //alert(href); }); }); </script> </head> <body> <h1>Test</h1> <p><a href="./test.html" class="spLink">Click</a></p> <p><a href="test2.html" class="spLink">Click</a></p> <p><a href="test3.html">Click</a></p> <div class="spResult"> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/246517-jquery-ajax-href-links/#findComment-1265849 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.