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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:02:41+00:00 2026-06-07T15:02:41+00:00

I wonder whether someone may be able to help me please. The extract of

  • 0

I wonder whether someone may be able to help me please.

The extract of code below successfully creates a table showing records pertinent to the current user.

/* display row for each location */ 
echo "<tr>\n"; 
$theID = $row['locationid']; 
echo " <td style='text-align: Center'>{$row['locationname']}</td>\n"; 
echo " <td style='text-align: Left'>{$row['returnedaddress']}</td>\n"; 
echo " <td style='text-align: Center'>{$row['totalfinds']}</td>\n"; 
echo " <form name= 'locationsconsole' id= 'locationsconsole' action= locationsaction.php  method= 'post'><input type='hidden' name='lid' value=$theID/>                                                 <td><input type= 'submit' name= 'type' value= 'Details'/></td><td><input type= 'submit' name= 'type' value= 'Images'/></td><td><input type= 'submit' name= 'type' value= 'Add Finds'/></td><td><input type= 'submit' name= 'type' value= 'View Finds'/></td><td><input type= 'submit' name= 'type' value= 'Delete'/></td></form>\n"; 
    </tbody> 
    </table> 
    <div align="center"><p id="deletelocationresponse"></p></div>

At the end of this section of code, you’ll see that there is a Delete button. Upon clicking this, a record is deleted from the table and the deletion functionality works correctly.

In addition to the delete button you’ll notice that there is a div called deletelocationresponse. This runs a jquery script to provide onscreen messages to the user telling them whether the deletion has been successful or not. The code for this is below.

<script type="text/javascript">
$(document).ready(function(){
    $('#locationsconsole').submit(function(){

        //check the form is not currently submitting
        if($(this).data('formstatus') !== 'submitting'){

            //setup variables
            var form = $(this),
                formData = form.serialize(),
                formUrl = form.attr('action'),
                formMethod = form.attr('method'), 
                responseMsg = $('#deletelocationresponse');

            //add status data to form
            form.data('formstatus','submitting');

            //show response message - waiting
            responseMsg.hide()
                       .addClass('response-waiting')
                       .text('Please Wait...')
                       .fadeIn(200);

            //send data to server for validation
            $.ajax({
                url: formUrl,
                type: formMethod,
                data: formData,
                success:function(data){

                    //setup variables
                    var responseData = jQuery.parseJSON(data), 
                        klass = '';

                    //response conditional
                    switch(responseData.status){
                        case 'error':
                            klass = 'response-error';
                        break;
                        case 'success':
                            klass = 'response-success';
                        break;  
                    }

                    //show reponse message
                    responseMsg.fadeOut(200,function(){
                        $(this).removeClass('response-waiting')
                               .addClass(klass)
                               .text(responseData.message)
                               .fadeIn(200,function(){
                                   //set timeout to hide response message
                                   setTimeout(function(){
                                       responseMsg.fadeOut(300,function(){
                                           $(this).removeClass(klass);
                                           form.data('formstatus','idle');
                                       });
                                   },2000)
                                    setTimeout(function() { 
                                    $('body').fadeOut(400, function(){
                                    location.reload();
                                    setTimeout(function(){
                                    $('body').fadeIn(400);
                                     }, 500);
                                     window.scrollTo(x-coord, y-coord);
                                 });
                            }, 2000);                           
                        });
                    });
                }
            });
        }

        //prevent form from submitting
        return false;
    });
});
</script>
<style type="text/css">
#deletelocationresponse {
    display:inline;
    margin-left:4px;
    padding-left:20px;
    font:Calibri;
    font-size:16px;
}

.response-waiting {
    background:url("images/loading.gif") no-repeat;
}

.response-success {
    background:url("images/tick.png") no-repeat;
}

.response-error {
    background:url("images/cross.png") no-repeat;
}
</style>

The problem I’m having is that when the Delete button is clicked the onscreen message is stuck on the Please wait message.

Now I know this script works, because I use it on my other pages, obviously with the relevant fields changed. So I’ve narrowed it down to a problem in it picking up my form name, which is this line in the jQuery code: $('#locationsconsole').submit(function(){.

On my other pages my form is created via HTML whereas this script uses PHP.

I’ve tried researching this, but I’m not particularly well versed in JavaScript, so I’m not too sure what I should be looking for. Could someone possibly tell me please is there a way to call the form in a different way?

Any help would be gratefully appreciated.

Many thanks and kind regards

  • 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-07T15:02:42+00:00Added an answer on June 7, 2026 at 3:02 pm

    The first step is to do basic debugging. FireBug, or other client side debugging tools can give you a lot of power. You can also start putting in alerts. For example, you can put a code like alert('got here!'); inline in the javascript to see which line specifically is throwing the error. If you are using FireBug, you can replace this with console.log('got here');

    console.log will also allow you to dump nested variables, if you find the problem is in your response.

    Secondly, save the rendered page as HTML, and then start to troubleshoot that. This eliminates the PHP side of the debugging, since you have either a HTML error or an error in the JSON response from the AJAX request.

    Client side debugging tools like Firebug will also let you see the AJAX request and the raw response.

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

Sidebar

Related Questions

I wonder whether someone may be able to help me please. The code below
I wonder whether someone may be able to help me please. The code below
I wonder whether someone may be able to help me please. Firstly apologies as
I wonder whether someone may be able to help me please. I'm using the
I wonder whether someone may be able to help me please Firstly, my apologies
I wonder whether someone may be able to help me please. Firstly, this is
I wonder whether someone may be able to help me please. Firstly, my apologies
I wonder whether someone may be able to help me please. I feel I
I wonder whether someone may be able to help me please. Firstly my apologies.
I wonder whether someone may be able to help me please. I'm using Aurigma

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.