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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:29:05+00:00 2026-06-08T09:29:05+00:00

I am using jQuery and PHP to save content that the user inputs in

  • 0

I am using jQuery and PHP to save content that the user inputs in a database. While the PHP is doing its thing I want to show a loading GIF image just to show that it is saving their data. I realize that it probably does take that long for it to run the code so i want to be able to show the image for at least 1 second if it takes less time than that

  • 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-08T09:29:06+00:00Added an answer on June 8, 2026 at 9:29 am

    For example, I’m using the following script as a live search form in a database.
    The user types some letters and the script search if a student with that name exists in the database:

    file index.php

    <head>
    //call to jquery.js
    <script type='text/javascript'>
    $(document).ready( function() {
     $('#q').keyup( function(){
      $field = $(this);
      $('#results').html('');
      $('#ajax-loader_e').remove();
    
      if( $field.val().length > 1 )
      {
        var str='q='+$(this).val();
        $.ajax({
          type : 'GET',
          url : 'ajax_search.php' ,
          data : str ,
          beforeSend : function() {
           $field.after('<img src="../img/ajax-loader.gif" alt="loader" id="ajax-loader_e" />');
          },
          success : function(data){
            $('#ajax-loader_e').remove();
            $('#results').html(data);
          }
        });//end ajax
      }//end if     
     });//end keyup
    });//end ready
    </script>
    </head>
    <body>
    <form class="quick_search">
      <input type="text" value="Name" id="q" name="q" onfocus="if(!this._haschanged){this.value=''};this._haschanged=true;">
    </form>
    <div id="results_e"></div>
    

    file ajax_search.php

    if(isset($_GET['q'])){
      $nom='%'.safe($_GET['q']).'%';
      $req=$connexion->prepare("SELECT * FROM students WHERE name LIKE :name LIMIT 0,10 ");
      $req->execute(array('name'=>$name));
      echo "<ul>";
      while($row=$req->fetch(PDO::FETCH_ASSOC)){
        if(empty($row)){
          echo "<h4 class='alert_error'>No one with that name!</h4>";
        }
        else{
          echo "<li><strong><a href='?id=".$row['id']."'>".clean($row['nom']).' '.clean($row['prenom'])."</a></strong></li>";
        }
      }
      echo "</ul>";
    }
    

    You can use that script to save a form via ajax and display a loader gif while waiting.
    The important parts are:

    • remove the loader in the beginning
    • in beforeSend, display the loader
    • remove the loader in success
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write JSON data to a text file using jQuery and PHP.
using jquery's .post i send do my php code an object that with var_dump
I'm using jQuery + PHP + MySQL My problem is how to save for
So I'm using jQuery to POST some items and save into the database. I
I need to set a PHP $_SESSION variable using the jQuery. IF the user
I pass form data to php using jquery code then the php code save
I am using jQuery to post a form field to a PHP file that
hello frieds this is how i usually post a variable using Jquery.. $.post(include/save_legatee.inc.php, {
I have implemented the image upload code using jquery php in my php web
I am using a bespoke JQuery/PHP script which parses a Flickr feed using SimpliePie

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.