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 9296799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T21:54:44+00:00 2026-06-18T21:54:44+00:00

EDIT JQUERY-AJAX REQUEST CODE: <script type=text/javascript> $(document).ready(function(){ $(.form).submit( function(e) { e.preventDefault(); var form =

  • 0

EDIT

JQUERY-AJAX REQUEST CODE:

<script type="text/javascript">
$(document).ready(function(){
$(".form").submit( function(e) {
    e.preventDefault();
    var form = $(this);
    var div_add_comment = $(form).parent();
    var div_comments = $(div_add_comment).parent();
    $.ajax({
        type: "POST",
        data: $(form).serialize(),
        url: "includes/comment.php",
        success: function(msg){
            $(div_comments).html(msg);
        }
    });
    return false;
});
});
</script>

JQUERY SHOW ALL – COLLAPSE COMMENTS CODE

<script type="text/javascript">
$(document).ready(function(){
$('.see_all').click(function(){
    var thisItem = $(this);
    thisItem.parent().find('#comment2').slideDown('fast');
    thisItem.parent().find('.collapse').css('display','inline-block');
    thisItem.css('display','none');
    return false;
}); 

$('.collapse').click(function(){
     var thisItem = $(this);
     thisItem.parent().find('#comment2').slideUp('fast');
     thisItem.css('display','none');
     thisItem.parent().find('.see_all').css('display','inline-block');
     return false;
})
})
</script>

JQUERY REMOVE DEFAULT VALUE TEXT UPON FOCUS – TEXTAREA

<script type="text/javascript">
$(document).ready(function(){
var Input = $('textarea[name=comment]');
var default_value = Input.val();

$(Input).focus(function() {
    if($(this).val() == default_value)
    {
         $(this).val("");
    }
}).blur(function(){
    if($(this).val().length == 0)
    {
        $(this).val(default_value);
    }
});
})
</script>

Please let me know if you need anything else, I have the damndest of time copying code and formatting it in these posts.

END EDIT

I am having a weird little problem. I have created a jquery-ajax function to transfer data from a comments section of my page. The page has an instance of this form under each user post. So this page will have X amount of posts with X amount of comments for each posts, like a social network. My ajax request sends, recieves and displays the data perfectly BUT I have two other jquery functions called on elements inside that no longer work after the ajax function returns the html. All the other ones not acted upon by the ajax function STILL WORK. I have the checked and rechecked the response html from the ajax function and it is identical to the html of a standard post-comment instance.

Please let me know what you would like to see or if you have questions.

Thanks, your help is always 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-18T21:54:46+00:00Added an answer on June 18, 2026 at 9:54 pm

    Be sure to bind the jQuery functions in such a way that the element doesn’t have to exist.

    $('ul').on('click', 'li', function(){ /* do something */ });
    

    This will execute on LIs that have been added after the binding of the function.

    In your case you would want to bind to the parent of the comments section and target the elements that have the click behavior.

    $('.comments')
        .on('click', '.see_all', function(){...})
        .on('click', '.collapse', function(){...})
        .on('focus', 'textarea[name=comment]', function(){...})
        .on('blur', 'textarea[name=comment]', function(){...})
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the below jQuery code: $(document).ready(function () { $('#ajaxButton').click(function () { $.ajax({ url:
right now , I use jQUery(document).ready to inject javascript into a div. All is
I'm using jquery to create some Ajax request, the code apparently is working fine;
I'm going to edit an ImageField using jquery ajax,after searching I found out I
Edit: Entire page (HTML) <!doctype html> <html> <head> <meta charset=utf-8 /> <title>jQuery Ajax Test</title>
I have this html code that i want to edit with jQuery. Here is
I am using a jQuery jEditable edit-in-place field but when the JSON function returns
I'm having some issues with a jQuery AJAX call. My code works fine when
I've found a possible bug while i was using jquery and Ajax function on
I have a situation where I send jquery ajax post request but in my

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.