Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8617531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:52:58+00:00 2026-06-12T05:52:58+00:00

I have a function to load page content via ajax, essentially the function, fades

  • 0

I have a function to load page content via ajax, essentially the function, fades out the current content, replaces the content with the result of the ajax request and then fades the content back in.

My function works fine for most pages but for some reason on one particular request the content is being loaded but the ajax success function is not being called meaning the content is loaded but remains hidden.

Here is my code, for the purposes of diagnosis I have replaced the ajax success function with an alert but this is not running on the same page (but ajax content IS being loaded):

var loadUrl=b_url+page;
        if (History.enabled) {History.pushState({state:2}, page, "/"+page);}
        window.name=page;
        $.ajax({
            cache: false,
            async: false,
            type: "POST",
            url: loadUrl,
            dataType: "html",
            beforeSend: function() {
                 $('.contentarea').animate({
                        'opacity'   : 0
                    }, 180, 'jswing', function(){
                            $('#mainc').hide(350, 'jswing');
                });
             },
            success: function(response) {
                $('#mainc').html(response);
                alert('success')
            },
            failure: function(msg) {
                alert('FAIL');
            }
        });

With the above code, neither a success or failure message is being displayed on the problem page, however if I remove the line:

$('#mainc').html(response);

Then the success message is displayed. The content being loaded is a page of html, which as I say appears to be loaded fine (in the sense that it is in the document). Every page bar one works fine so I suspect there is some problem with what is being returned (although it loads to the document fine) – The content being loaded is built out of a load of partials using codeigniter so I suppose my question here is how I go about working out what the problem is. I have tried adding this in my document ready function (having read a similar post) but it does nothing:

$(document).ajaxError(function(e, xhr, settings, exception) {
alert('error in: ' + settings.url + ' \n'+'error:\n' + xhr.responseText );
}); 

An ideas how I go about finding out what the problem is here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T05:52:59+00:00Added an answer on June 12, 2026 at 5:52 am

    For the .ajaxComplete – you should have that registered as part of your page load on the element being loaded into – so

    $('#mainc').ajaxComplete(function(){ alert('bob')})
    

    can be it’s event instead of being buried inside of the .animate function. Otherwise the line:

    $("#mainc").load(loadUrl);
    

    could include your oncomplete function directly instead of registering the event listener. e.g.

    $("#mainc").load(loadUrl, function(){ alert('bob' });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have multiple divs in a page whose content gets loaded via ajax. I
I'm using ajax to load a page $.get(url, function(content){ //ajax content }); on the
I am using following function to load the page. I have loads of links
i have many events such as $('.hidefile').click(function (event) { On page load and on
I'm loading image tags via AJAX and inserting them with the conventional .html(content) function
I'm having an issue with colorbox when I have loaded content via AJAX. I
I have created jquery-ajax call for php page that creates content by selecting data
So...um, how can I load a specific DIV from a page loaded via ajax?
I've previously used jquery-ui tabs extension to load page fragments via ajax , and
I have a div on my page that gets populated via an ajax call

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.