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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:09:08+00:00 2026-06-12T15:09:08+00:00

My page loops database values that are editable and updated without refresh via ajax.

  • 0

My page loops database values that are editable and updated without refresh via ajax.
The logic works just fine, but I can’t get the success message to act correctly. As of now, the message flashes on ALL div’s with class .status… I’ve tried prevAll,parents,closest, etc but can’t quite get the message to ONLY display on the form that was clicked.

$(document).ready(function() {      
    $(".save").click(function (e) {         
        var content = $(this).prevAll('.editable').html();  
        var item = $(this).prevAll('.item').html(); 

    $.ajax({
        url: 'save.php',
        type: 'POST',
        data: {content: content, item: item},               
        success:function (data) {
            if (data == '1'){
                $(".status")
                .addClass("success")
                .html("Data saved successfully")
                .fadeIn('fast')
                .delay(3000)
                .fadeOut('slow');   
            }
         }
     });        
     });
});

The form structure (keep in mind, it is looped).

<div id="wrap">
    <div class='status'></div>
    <div id='content'>
        <div class='editable' contentEditable='true' ></div>
        <div class="item"></div>    
        <button class="save" style="display:none">Save</button>
    </div>
</div>
  • 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-12T15:09:09+00:00Added an answer on June 12, 2026 at 3:09 pm

    That’s because you’re not specifying which .status you want to light up.

    Here’s a fiddle.

    PS: I changed some code for it to work in jsiddle so you need to adapt.

    PS2: I suggest you use class names instead of ids because my guess is that they will repeat and ids should be unique.

    $(document).ready(function() {      
            $(".save").click(function (e) {         
                var content = $(this).prevAll('.editable').html();  
                var item = $(this).prevAll('.item').html();
                var statusItem = $(this).parents('.wrap').find('.status');
            $.ajax({
                url: '/echo/html',
                type: 'POST',
                data: {content: content, item: item},               
                success:function (data) {
                    //if (data == '1'){
                         statusItem
                        .addClass("success")
                        .html("Data saved successfully")
                        .fadeIn('fast')
                        .delay(3000)
                        .fadeOut('slow');   
                    //}
                 }
             });        
             });
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to build an edit page for a database record that can be
I have a page that searches a database and generates the following array. I'd
I'm using the Scriptaculous Ajax.InPlaceEditor to edit data from my database. Actually, it works
Background I have a form that PHP generates from my database. The page is
I have a page which displays my database information. Through each loop, there is
The code behind file creates a list of employees and the asp.net page loops
Is there a way to make a triangular float so that a page looks
I have a page that looks like this: Head and body tags... <form runat=server>
In our database we have a bitmask that represents what types of actions a
My page shows posts stored in my Database through a loop. Each post is

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.