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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:14:14+00:00 2026-06-11T23:14:14+00:00

When the user clicks on a remove button, the code sends a request to

  • 0

When the user clicks on a remove button, the code sends a request to the server to remove that user from the DB first and then from the table list on the screen.

My problem is that a if else statment withint the ajax success does return what I want.

I can’t add this code to fiddlers because it’s linking to a database which is not accessible online.

$(nTd).children('a').click(function(e) {
    e.preventDefault();
    var that = $(this);
    if(that.hasClass('icon-i-remove')){
       $.ajax({
          url: $(this).attr('href'),
          type: $(this).attr('method'),
          dataType: 'json',
          success: function (data) {
            //PROBLEM HERE **********
            if(data.success == 'true' ){
               alert('true');
            } else {
               alert('false')
            };
       ;}
   });

So, 2 major problems.
The if statement doesn’t run correctly. even if it return true, the server jumps to the else without caring about it.

The second issue is this.
When the user clicks on the remove button, the code should first check if the user has been deleted on the DB. If I have the ok from the DB, then I can remove the row from the table list without refreshing the page, otherwise I should display an error message (false return)

In my case, when I click remove, the code send a request to the server and doesn’t care what the result is.

I need the code to wait before executing the client side remove. I need to know if that user has been removed from the db or not.
I find it difficult to manage the if statement do. It seems it’s not looking at the result back from the backend.

True or false it skips through either way. What’s going wrong?

  • 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-11T23:14:15+00:00Added an answer on June 11, 2026 at 11:14 pm

    Is it actually returning 'true'? Or is it returning true? Two different things

    UPDATE

    $(nTd).children('a').click(function(e) {
        e.preventDefault();
        var that = $(this);
        if(that.hasClass('icon-i-remove')){
           $.ajax({
              url: $(this).attr('href'),
              type: $(this).attr('method'),
              dataType: 'json',
              success: function (data) {
                //PROBLEM HERE **********
                if(data.success == true ){   <-- Change to true (remove quotes)
                   alert('true');
                } else {
                   alert('false')
                };
           ;}
       });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The code below is intended to enable the submit button once the user clicks
I have the following code running when the user clicks the Save button: -
When the user clicks on a button, a new ListFragment is displayed. This fragment
When the user clicks add more options, a from is created with javascript document.getElementById('addmore').innerHTML
When a user clicks a table row, I use jQuery to select the link
When a user clicks a submit button I want the form to be submitted.
I am trying to create two form elements when the user clicks a button,
In my website when the user clicks on the Logout button, the Logout.aspx page
I have an application that has 2 screens. The first screen has a ListView
I've have an ImageButton within a ListView . When a user clicks the button

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.