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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:14:20+00:00 2026-05-26T19:14:20+00:00

I am trying to delete the data against the remove (Ajax) option.When i click

  • 0

I am trying to delete the data against the remove (Ajax) option.When i click the remove button it deletes the data from the database and the page should automatically disappear the data.But it does not happen,it deletes the data but not disappeared from the screen.When i refreshed the page then in the page the data is disappeared……Please help me

The html code…

<table><tr><td><a href="javascript:remove()">Remove</a></td>
                 <td id="resId"></td></tr></table>

The ajax function is….

function remove(){
       var http = GetXmlHttpObject();
        http.onreadystatechange = function()
        {
            if(http.readyState==4)
            {
                document.getElementById("resId").innerHTML = http.responseText;
                //alert(http.responseText);
            }
        }
        var name1 = document.getElementById("bn").innerHTML;
        //alert(name);

        var url = "index.php?menu=remove_cart&ajax=ajax&q="+name1;
        http.open('POST',url,true);
        http.send(null);
    }

And the PHP function is….

function remove_cart($name1){
    global $template;

    $sql = "DELETE FROM tbl_buy WHERE b_name = '$name1'";
        $this->db->executeQuery($sql);

      $template->main_content = $template->fetch(TEMPLATE_DIR . 'my_cart.htm');
}
  • 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-26T19:14:21+00:00Added an answer on May 26, 2026 at 7:14 pm

    By using AJAX to modify your database, you have disabled the browser’s default refresh mechanism: the page reload. Therefore, you have to provide your own page refresh mechanism with JavaScript. You’ll want to add some custom success messaging in your PHP that tells your JS that everything is good.

    if(http.readyState==4)
    {
        document.getElementById("resId").innerHTML = http.responseText;
        //alert(http.responseText);
        if (http.status==200){ //on successful server response
            //check responsetext for successful DB delete
            if ('successful DB delete'){ //pseudo-code condition
                //javascript to remove element representing the DB row from the HTML DOM
                //ie. element.parentNode.removeChild(element);
            }
        }
    
    }
    

    For the ‘element’ JS variable to mean the element that was clicked, modify your remove() function and the way it’s called:

    function remove(element){
        //...
    }
    

    and

    <table><tr><td><a href="javascript:remove(this.parentNode.parentNode)">Remove</a></td>
                     <td id="resId"></td></tr></table>
    

    where this.parentNode.parentNode references the <tr> above the <a>.

    Hope that helps.

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

Sidebar

Related Questions

While trying to delete the data from my SQL Server CE 3.5 database, I
I was trying to delete a data from database using jquery and the following
I'm trying to delete one row of data from a MySQL database (innodb) in
I am trying to delete several rows from a MySQL 5.0.45 database: delete from
I'm trying to delete all digits from a string. However the next code deletes
I am trying to delete items from listbox which is data bound. Here is
I'm trying to delete all data related to a user id from a game
I am trying to delete data from a table using a SQLDataAdapter , and
I am trying to delete the data from table older than 6 months where
I'm trying to delete something from my mongoDb database based on the _id and

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.