views:

26

answers:

1

Hi. I am creating a portfolio page for m personal site. I have a slider with a bunch of anchors that relate to projects I have worked on, each one contains a client logo that when clicked should load a html page into a div on the same page. I would like to use JQuery to achieve this my question is which method would I use load() or ajax(). This is not something I have done before so I'm a little confused what the difference is.

Also if it makes any difference to my question I will be making the site content managed with MODX very soon.

Many thanks in advance.

+1  A: 

load() is just a shortcut for ajax() method with certain options. If you only need to fetch page and place it in the dom you can use load() method. If you need more control over the ajax request or you need to call it with some other options then go for ajax()

Giorgi
@Giorgi I do want to fetch and place the page, ideally I'd like to wait until it loads then fade the page in, would this be a job for ajax()?
mtwallet
@mtwallet ajax() is for controlling the fetching itself and not animations. You can pass callback to load() which will be executed once the request completes.
Giorgi
@Giorgi thanks a lot for the help I appreciate it
mtwallet
@Giorgi one last question if I may. Would I have to use unload() first to ensure the div I am placing content into is empty?
mtwallet