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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:01:07+00:00 2026-06-17T20:01:07+00:00

I would like to be able to star/un-star any given conversation (like Gmail for

  • 0

I would like to be able to star/un-star any given conversation (like Gmail for example.) When I click the “empty” star to mark something as important, I need to submit some ajax and then toggle to the star image. And visa versa, when I click a starred conversation, I need the ajax to submit and upon its success, then have “empty” star toggled back.

Some HTML (in a nutshell):

 <div class='__conversation'>
      <div class='__conversation_star'>
         <img class='__star_n' src='p_star_n.png'/>
         <img class='__star_y' src='p_star_y.png'/>
      </div>
 </div>

And something with similar functionality to a basic:

    $(".__conversation_star").click(function() {
         $(this).find('img').toggle();
    });

Some ajax:

 $(".__conversation_star").click(function() {
    jQuery.ajax({
        type: 'POST',
        url: "./process.conversation.php,
        data: {method: 'star'},
        cache: true,
        success: function() {
            // Toggle to un-starred .__star_n
        }
    });
 });

 $(".__conversation_star").click(function() {
    jQuery.ajax({
        type: 'POST',
        url: "./process.conversation.php",
        data: {method: 'star'},
        cache: true,
        success: function() {
            // Toggle to starred .__star_n
        }
    });
 });

Is there a way I can perform a toggle upon success of the ajax? and/or what other methods of doing this are there that will work better?

Thank you!

  • 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-17T20:01:08+00:00Added an answer on June 17, 2026 at 8:01 pm

    Instead of toggling which image shows, it might be easier to toggle a CSS class instead. So if your HTML was set up like this:

    <div class="conversation">
        <span class="star"></span>
        <span>blah blah blah blah</span>
    </div>
    

    and then you had the following CSS:

    .conversation{
        padding:3px 5px;
        border: 1px solid #CCC;
        margin-top:3px;
    }
    
    .star{
        background-color: hsl(200, 90%, 90%);
        border:1px solid #333;
        display:inline-block;
        height:20px;
        width:20px;
    }
    
    .star.state-selected{
        background-color: hsl(60, 70%, 60%);
    }
    

    Now all you have to do is toggle the class state-selected on each <span class='star'>

    Here is some example JavaScript

    $(".star").click(function() {
        var $thisStar = $(this);
        
        $.ajax({
            type: 'POST',
            url: "./process.conversation.php",
            data: {method: 'star'},
            cache: true,
            success: function() {
                $thisStar.toggleClass("state-selected");
            }
            
        });
        
    });
    

    DEMO: http://jsfiddle.net/fbvg9/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Would like to be able to set colors of headings and such, different font
I would like to be able to output the name of a variable, along
I would like to be able to print in the logs a message for
I would like to be able to show a personal message to abusers of
I would like to be able to create a variable that holds an instance
I would like to be able to go: sed s/^\(\w+\)$/leftside\1rightside/ and have the group
I would like to be able to define a function which accepts an argument
I would like to be able to redirect if a route constraint fails, rather
I would like to be able to add the help button onto my winform,
I would like to be able to scroll further down in Eclipse, below the

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.