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

  • Home
  • SEARCH
  • 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 8178709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:49:47+00:00 2026-06-06T23:49:47+00:00

There seems to be others having similar problems but still not finding an answer.

  • 0

There seems to be others having similar problems but still not finding an answer. Here is the scenario.

The user clicks a button which shows a hidden div containing a textarea where they can make a comment:

//show the div containing the textarea
$('#postTypeContainer').css({ 'display': 'block' });

Next the user enters a comment and clicks a button to submit and the div is hidden and some data is sent to the server:

$("#loading").ajaxStart(function () {
        $(this).show(); //shows a spinner
    }).ajaxComplete(function () {
        $(this).hide(); //hides the spinner

        //hide the div that was opened earlier
        $('#postTypeContainer').fadeOut('fast');
    });

    //send data
    $.ajax({
        type: "POST",
        url: rootUri + "main.aspx/StartNewThread",
        data: jsonText,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (markUp) {
           //stuff
        }
    });

This all works as it should.

Now the user opens the div again via a click which works just fine

//show the div containing the textarea
$('#postTypeContainer').css({ 'display': 'block' });

Next the user types some data, in this case an @abc because they want to tag another user and the following occurs using jQuery on ‘keyup’:

//ajax call to find users matching the @abc
$.ajax({
        type: "POST",
        url: rootUri + "main.aspx/GetMatch",
        data: jsonText,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (data) {

            //stuff

        }
    });

As soon as this ajax call returns the div that was opened is closed as if the DOM is being reset to what it was prior to the ajax call. So in the middle of trying to interact with the textarea, the div closes on the user which is very frustrating. The only way to fix this is to refresh the page which is obviously what I want to avoid by using ajax. Hoping someone has an idea of what’s wrong. The one thing I have tried unsuccessfully is when entering the function on keyup that makes the ajax call for tagging, I check the state of the div and then try to set it at the end of the ajax call to keep it open but that is not working. Any help is appreciated.

  • 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-06T23:49:48+00:00Added an answer on June 6, 2026 at 11:49 pm

    .ajaxComplete() is a global ajax event, fired every time a jQuery ajax event completes. So when your second ajax call completes it also hides the postTypeContainer div. I think you want to bind that hiding to the local complete event for that first ajax call.

    $("#loading").ajaxStart(function () {
        $(this).show(); //shows a spinner
    }).ajaxComplete(function () {
        $(this).hide(); //hides the spinner
    });
    
    //send data
    $.ajax({
        type: "POST",
        url: rootUri + "main.aspx/StartNewThread",
        data: jsonText,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (markUp) {
           //stuff
        },
        complete: function() { // DO IT HERE
    
            //hide the div that was opened earlier
            $('#postTypeContainer').fadeOut('fast');
    
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There seems to be a similar question to this on here but with the
There seems not to be an SDK 2.x.x for Snow Leopard. Or am I
This question seems similar to those asked in a few other posts: here and
This may not seem like a development question but there is a link. I
There are a few similar questions, but nothing like this. How do you deal
I'm using ASIHTTPRequst in my application and im having some problems, but only on
I have been pouring over many forums and questions similar (but not the same)
There seems to be a breaking (i.e. backwards-incompatible) change in the CSS Syntax Module
There seems to be a lot of questions asking for regex to detect a
There seems to be a distinct lack of documentation of the GObjects module for

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.