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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:56:45+00:00 2026-05-27T16:56:45+00:00

I am building a backoffice to a certain site, and here i need to

  • 0

I am building a backoffice to a certain site, and here i need to delete the comments from the database using ajax, the problem is i cant pass the id i want to hide after deleting to jquery in ajax. following is the code for the comments:

<% foreach (var item in Model) { %>
    <div class="row" id = "row<%= item.CommentID %>">
        <div class="editor-label detail">Comment</div>
        <div class="form-element"><%: Html.DisplayFor(modelItem => item.Text) %></div>
        <div class="editor-label detail">Date</div>
        <div class="form-element"><%: Html.DisplayFor(modelItem => item.Date) %></div>
        <div class="form-element">
        <div class="button delete"><%: Ajax.ActionLink("Delete", "Deletecomment", new { id = item.CommentID }, new AjaxOptions { HttpMethod = "POST", OnSuccess = "deleteRow" })%></div>
        </div>
    </div>
<% } %>

this is the code for the controller:

[AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Deletecomment(int id)
        {
            cr.Delete(cr.getComment(id)); //cr is the conx to the repository
            cr.Save();

            return View("Index");
    }

this is my jquery

function deleteRow() {
    var url_ = this.url.split("/");
    $("#row" + url_[url_.length - 1]).remove();
}

what i have done is taken the url and split it to take the id of the entry in db then add it to the form as id and then remove that id, but i am sure there is a better solution

  • 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-05-27T16:56:46+00:00Added an answer on May 27, 2026 at 4:56 pm

    Assuming you are using the jquery unobtrusive ajax script you could pass parameters to the callback:

    <%= Ajax.ActionLink(
        "Delete", 
        "Deletecomment", 
        new { 
            id = item.CommentID 
        }, 
        new AjaxOptions { 
            HttpMethod = "POST", 
            OnSuccess = "deleteRow('#row" + item.CommentID + "')" 
        }
    ) %>
    

    and then:

    function deleteRow(row) {
        $(row).remove();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

building a site using PHP and MySQL that needs to store a lot of
Building a website using a PHP based Ecommerce product Magento. The problem I have
building a site which has content for each section. urls range from; /work/ /work/print/
Building a relatively simple website, and need to store some data in the database
Building an MVC 2.0 web site and using Content Delivery Network (CDN) in my
I'm building a project using mvc framework. I'm at a point where i need
Building an application, before using a real database, just to get things work I
Building a sample ASP.NET MVC app. Using the Membership API for authentication. For whatever
Building an app using android.support.v4.app , targeting API level 8. Everything's working as planned
Building a site super quick and having it work on all my Mac browsers,

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.