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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:40:39+00:00 2026-06-10T15:40:39+00:00

I make product my favourite with Javascript yes no window. When click yes button,

  • 0

I make product my favourite with Javascript yes no window. When click yes button, product gets my favourite and refresh background page. I have MakeMyFavorite action in the controller, but it return same result every call.

public ActionResult MakeMyFavorite( int id )
{
   ....
   return RedirectToAction( "Details", "Product", product );
}

and Javascript:

<script language="JavaScript" type="text/javascript">
    function confirmFavorite() {
        if (confirm("Are you sure make favorite?")) {
            document.location.reload(true);
            return true;
        } else {
            return false;
        }
    } 
</script>

and link:

<a href="@Html.Action ( "MakeMyFavorite", "Product", new { id = item.ID } )" 
     onclick = "return confirmFavorite()"> Make Favorite </a> 

I use Make Favorite link in different places in the site (Details, Index and other views). When click link, product is favourite, page refresh, but always opens Details view.
I changed ActionResult with void in the controller, but never open, because, there is not return view.
How should I do, in different pages of site, when I click Make Favorite link, product is favourite, but background page not change? To stay current view. (Sorry for bad English)

  • 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-10T15:40:41+00:00Added an answer on June 10, 2026 at 3:40 pm

    You can do this

    Make a JsonResult Action

    Like

    public JsonResult MakeMyFavorite(int id)
    {
       ......
       string result = "favorite";
       return this.Json(result, JsonRequestBehavior.AllowGet);
    }
    

    Make your anchor tag like

    <a href="#" id="myfav" onclick="confirmFavorite(@item.id);">Favorite</a>
    

    and your jquery for handling this

    <script type="text/javascript">
        function confirmFavorite (id) {
            if(confirm("Are you sure make favorite?")) {
               var data = { "id": id };
               $.getJSON("/Product/MakeMyFavorite", data, function (data) {
                   //check your data here what it is returning
                   if($.trim(data)=="favorite")
                   {
                    //Do what you want to do.
                   }
               });
            }
         }
    
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Products:List<Product> class. I'd like to make it so that every time
I am trying to make a simple product-configurator thingie ... Right now I have
I recently make a product import script using PHP and Mangento API. I have
You usually invoke the following commands to build a ./configure d product: make make
We use Make to compile our product, which includes, C, C++, Java and a
I'm trying to make a paginate mechanism for our product documents stored in MongoDB.
I need help on figuring how to make a link for my Product that
Web-Applications these days make extensive use of Javascript, for example various Google Products like
Hey there, I'm at the moment trying to make a product management application. The
Say I've been tasked to architect a product that will have a browser-based front

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.