Results 1 to 3 of 3

Thread: AJAX Callback problem

  1. #1
    Join Date
    Jul 2010
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default AJAX Callback problem

    1) Script Title: Dynamic Ajax Content

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...jaxcontent.htm

    3) Describe problem: I'm using this script on my site and then using ColourBox to display a gallery however when the links are clicked on the loaded page they don't show the ColourBox effect they simply load in the same window.

    However when I load the page on it's own it works fine, spoke to the tech guys who wrote it and they have said I should use the Callback function in the AJAX code, thought that this was the

    loadobjs() but this didn't change anything.

    Please any ideas would be really helpful I'#ve been going round in circles for 2 days now!!!!

    the site is here www.tufcoat.co.uk/2010 and the code is implemented on the products tab>construction grade

    Barry

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,165
    Thanks
    44
    Thanked 3,239 Times in 3,200 Posts
    Blog Entries
    12

    Default

    The loadobjs() thing is a red herring, don't use it. The scripts and styles you need should already be on the 'top' page (the one at http://www.tufcoat.co.uk/2010/). You already have jQuery there (though you may want to upgrade it to v1.4.2), so just add the colorbox.js (after jQuery) and the colorbox.css. Just make sure that the paths to them are correct for that page. The 'callback function' in this case is (in the main Ajax Content script):

    Code:
    function loadpage(page_request, containerid){
    if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
    document.getElementById(containerid).innerHTML=page_request.responseText
    }
    And what they told you is correct. If you follow javascript at all, what the above function does is load the result of the request into the contentarea division (or to whatever division you have designated as the contentarea division). You can add to the function:

    Code:
    function loadpage(page_request, containerid){
    if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){
    document.getElementById(containerid).innerHTML=page_request.responseText
    some code here to init the imported color box stuff
    }
    }
    Notice the two added red braces. Just what that code would be depends upon what's available in Color Box and how you are using it. I'm guessing (from looking at the source code of your construction_grade.html page & reading over the Color Box docs a bit) that you could replace the green line with:

    Code:
    $("a[rel='tufcoat_product']").colorbox();
    In this particular case I don't think it matters that often there will be no a[rel='tufcoat_product], because Color Box should gracefully do nothing in cases like that.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    bjkirkham (07-26-2010)

  4. #3
    Join Date
    Jul 2010
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Smile Thanks a million

    Worked perfectly, thank you very much!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •