Jump to content
Sign in to follow this  

loading image during ajax process not working properly

Recommended Posts

loading image during ajax process not working properly:


my code smthing like this...


div to show content and loading image-

<div id="adS" style="float: left; width: 70%">
    <div id="loading-image" style="background-image: url('images/processing.gif'); display: none;">


jquery code-

$(function() {

        $("#lets_search").bind('submit',function() {
          var gen = $("input[name='radGen']:checked").val();
          var mt = $('#selMtQ').val();
          var agf = $('#agf').val();
          var agt = $('#agt').val();
          var rel = $('#religQ').val();
          var cast = $('#selCstQ').val();
           $.post('adSearch.php',{gen:gen,mt:mt,agf:agf,agt:agt,rel:rel,cast:cast}, function(data){
           return false;

The loading image show only one time on click event.. not every time when i click search li... :(


Need help...

Share this post

Link to post
Share on other sites

I don't see the html associated with the jQuery which would be helpful. Anyways...

'bind' is not the preferred method for attaching events, it's 'on'. You attach the submit event on the form, not a button and there is a shortcut for doing that.

$("#id-of-form").submit(function(e) {
	//stop the default form submission

	//....rest of the code

If your ajax returns fast then you might miss the loading image as it did not have enough time to load before being hid again.

Don't hide the loading image and see if it displays. If it does, then you know it's working and the ajax speed is the issue. 

Edited by hansford

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.