add to the script:

return false;

to prevent the default <A> behaviour


$(document).ready(function(){
$('a.ajaxLink').click(function(){
var url = $(this).attr('href');
$('#ihateiframes').empty().load(url);
});
return false;
});


On Mon, Dec 29, 2008 at 3:32 PM, BlueStunt <bluest...@gmail.com> wrote:
>
> I'm trying to do the same thing, the code you suggested works, but the
> text on the page changes to what's in the html file I link to but then
> the browser also moves to the page, how do i stop this?
> On Dec 22, 1:51 pm, "Alexandre Plennevaux" <aplennev...@gmail.com>
> wrote:
>> say the container that will display the loaded content, i.e, your iframe
>> becomes
>>
>> <div id="menu">
>> <a href="page/to/load.html" class="ajaxLink">click me</a>
>> <a href="page/to/load2.html" class="ajaxLink">click me 2</a>
>> <div id="ihateiframes">
>> <p>this will be replaced</p>
>> </div>
>>
>> your javascript will be:
>>
>> $(document).ready(function(){
>> $('a.ajaxLink').click(function(){
>> var url = $(this).attr('href');
>> $('#ihateiframes').empty().load(url);
>>
>> });
>> });
>> On Mon, Dec 22, 2008 at 6:51 AM, Ayan <ios...@gmail.com> wrote:
>>
>> > Hi
>>
>> > Currently my page has a iFrame (loads an external web-page) in it.
>>
>> > I have seen this tutorial that uses simple AJAX to replace this
>> > iFrame.
>> >http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm
>> > (see the small DEMO, I want exactly the same with just 2 Links)
>>
>> > My question is - How can I do the same using jQuery's AJAX to do the
>> > same ?
>>
>> > Thats is, when these 2 Button/Link hit, it will fetch corresponding
>> > remote html and paste it in a DIV. Thats it.
>>
>> > Please do reply.....
>>
>> > Ayan Debnath
>> > INDIA.
>

Reply via email to