Javascript/AJAX - Show image whilst update is done and then hide it.

I want to do an update with AJAX but I want a "waiting" image to display before the update and then hide afterwards. That way, if there is a delay in the update or a row lock, the screen doesn't just freeze, it shows a "please wait" icon.
I am using code like this to save to the database when a field is de-selected (done for ease of testing):
<script type="text/javascript">
function deselect_field(f) {
  f.disabled=true;
  f.className=f.className + " saving";
  var v=new htmldb_Get(null,&APP_ID.,'APPLICATION_PROCESS=SC_TEST',0);
  v.add(f.name,f.value);
  v.get()
  f.className=f.className.replace("saving"," ");
  f.disabled=false;
</script>The saving class sets the background. I have tested this without the un-setting and it works fine. I think the issue is the ajax call is made too quickly, ie before the screen has had chance to update.
SO - my question is, how can I have the image (moving gif) display whilst the AJAX call is processing and then hide it at the end?!
Rather not use JQuery if possible.
Thanks

Hi,
Thanks for the link. The issue I'm having now is that the process isn't firing (it's just updating a row in a table). Also, readyState of 4 never seems to get returned. I seem to get the call for readyState of 1 and then that's it. I've modified my code:
<script type="text/javascript">
var z;
function deselect_field(f) {
  z=f;    
  var v=new htmldb_Get(null,&APP_ID.,'APPLICATION_PROCESS=SC_TEST',0);
  v.add(f.name,f.value);
  v.GetAsync(f_async);
  v=null;
function f_async() { alert(p.readyState);
  if (p.readyState==1) {
    z.disabled=true;
    z.className=z.className.replace("highlight_field"," ");
    z.className=z.className + " saving";
  else if (p.readyState==4) {
    z.className=z.className.replace("saving"," ");
    z.disabled=false;
</script>As you can see, I have a debugging alert message in there. This only pops up the once with a value of "1".
Any ideas?! Apart from using classes instead of displaying the HTML element, I can't see much else that is drastically different? Even so, I wouldn't have thought that would have any effect anyway?
Thanks,

Similar Messages

  • Why do my raw images (fr Nikon d800e) show up bright for 1 second and then darken in Aperture?

    I'm new to this site so I apologize for the long question.  When I import raw files from my Nikon D800e into Aperture (3.2.3), they show up bright for one second and then darken slightly.  Is this normal?  It didn't happen with raw files from my Nikon D300.  I have to adjust the brightness and exposure to make them bright again.  thanks, Mike

    One of the changes in Aperture 3 as it has evolved, is to first use the Preview generated by the camera.  It waits to generate its own Preview until you actually click to display that one image.  Until then the thumbnails are based upon the camera provided JPEG Preview.
    In earlier versions, you never saw that, but only the initial Preview generated in Aperture.  It is not because of the different camera.
    Btw, if you are using 10.8.2, why have you not updated to Aperture 3.4.3?
    Ernie

  • HT4623 What does it mean after you update your phone and then your phone starts to blink on and off showing the apple logo only?

    What does it mean after you update your phone and then your phone starts to blink on and off showing the apple logo only?

    Read http://support.apple.com/kb/ht1808

  • Home Sharing shows up in iTunes until I hit Done and then it's gone forever.

    My router died a few days ago and I just received my new Aiport Express this morning and my network was up and running in minutes. Unfortunately, Home Sharing (which I really, really hate) is being a pain. I'm trying to get my Apple TV to connect to my iTunes (which worked before, by the way) but it says Home Sharing needs to be enabled.
    So, for fun, I disabled it and attempted to login. When I click on Home Sharing, the little house logo shows up in the left column. As I go through logging in, things are fine till I hite DONE and then the house disappears and never returns.
    At this point, done the following:
    1. rebooted both the router and the modem,
    2. disabled and enabled Home Sharing on iTunes and on the Apple TV
    3. made a new 'Test' Apple ID which doesn't seem to work properly anywhere so that was a bust.
    4. Considered telling Apple to take a flying leap (in less eloquent terms) as this is a stupid waste of time!
    5. Checked on both my iPhone 5s and my iPad and there's no sharing showing up. To me, it seems iTunes based.
    Why did it work fine before and not now? Why does this have to be so incredibly difficult to set up for something seemingly so easy? What can I do now?
    I'm on an iMac (all latest software, etc.), Apple TV Gen. 3.
    Thanks,
    Michael

    Oh... just to make it more bizarre, I have a second iMac and was able to set it up with Home Sharing but since it's not the main computer, I only get Music and Podcasts or something. Still attempting to figure out the other mess though.

  • While i was updating it was failed for 3 times and then i started to update it again and then it was showing as the product verification could not be verified and the product verification may be damaged or not signed

    while i was updating it was failed for 3 times and then i started to update it again and then it was showing as the product verification could not be verified and the product verification may be damaged or not signed

    Mavericks installer can’t be verified
    Mavericks Installer can’t be verified (2)
    Try running the combo update.
    10.9.2

  • I am trying to download Firefox and it gets to about 95% done and then it stops.

    I tried updating Firefox but it kept getting to around 95% done and then it just stopped. After about 10 minutes it would say that it could not download and to try from the site. I tried uninstalling Firefox to do a clean install like someone said online and I am still having the problem. I have tried using 2 different browsers to download it and it still gets almost there and then just stays there. Any help would be amazing

    Are you downloading the "full" installer from this page: [https://www.mozilla.org/firefox/all/]? If you are getting the "stub" installer, or choosing "Run" instead of save, try saving the full installer to the desktop and running it from there.
    Also, if you haven't shut down and restarted Windows since this problem began, please try that in case there are some Windows Installer issues like an accumulation of queued updates or crashed component.

  • I've updated my iphone and then the sound is cut off and sms what should i do ?

    i've updated my iphone and then the sound is cut off and sms what should i do ?

    You can try resetting your iPad by simultaneously pressing and holding the Home and Sleep/Wake buttons until you see the Apple Logo. This can take up to 15 seconds so be patient and don't release the buttons until the logo appears.
    Try again to see if the problem persists.

  • HT1414 It has some problem about my iphone. When I turn off the phone and then turn on, it shows the screen of apple page and then show the loading page many times. What happen with my iphone?

    I have iphone5s and there is some problem about my iphone. I turn off the phone and then I turn on. After I turned on, It showed the page of apple signal and then the page of loading. It used long time to show the loading page. Then it was back to page of apple and then loading page again many times. What happen with it? And what should I do?

    Did you already try to reset the phone again by holding the sleep and home button for about 10sec, until the Apple logo comes back again?
    If this does not work, try to set it up as new device, explained here:
    How to back up your data and set up as a new device
    You may have to connect in recovery mode, if the phone is not recognized in iTunes:
    iOS: Unable to update or restore

  • When i try to do a software update, it finishes and then says that the update cannot be saved because it has probably been corrupted during the download. This has happened a number of times and i do not know why, any help?

    When i try to do a software update, it finishes and then says that the update cannot be saved because it has probably been corrupted during the download. This has happened a number of times and i do not know why, any help?

    asifmanzoor wrote:
    i have 10.7.2, this download is 10.7.5
    Are you Downloading it from here  >  http://support.apple.com/kb/dl1582
    asifmanzoor wrote:
    yes, i am using wifi
    1)  Turn your Wi-Fi router OFF... wait 30 seconds... Turn it back ON.
    OR...
    Do not use Wi-Fi and connect Directly to your Internet via ethernet cable.

  • How do I get the Questions to show in the 'View Responses' TAB, and then show up in the Summary Report?

    How do I get the Questions to show in the 'View Responses' TAB, and then show up in the Summary Report?

    There are more than one Applications folders. At the root level of your system is an Applications folder for all users, where most installations go. Every user, including you, also has a separat Applications folder.
    Check all of them.

  • I am using an apple TV to show a slide show which is sent via WiFi from a mini computer.  The slide show repeats for a few hours and then stops and shows "no signal".  What's going on- and how do I get the show to cycle indefinitely?

    I am using an apple TV to show a slide show which is sent via WiFi from a mini computer.  The slide show repeats for a few hours and then stops and shows "no signal".  What's going on… and how do I get the show to cycle indefinitely?  (I have set the server to NEVER sleep)

    Welcome to the Apple Community.
    Have you also set the Apple TV not to sleep.

  • I recently updated my ipad and then  I connected with my computer forn sync, not realising that I had a new version of itunes with none of my apps. Now I have lost allof the apps and books etc, that I had prurchased. How do I get them back?

    I recently updated my ipad and then  I connected with my computer for sync, not realising that I had a new version of itunes with none of my apps. Now I have lost all of the apps and books etc, that I had prurchased. How do I get them back?

    As long as the apps and ibooks are still available in the store, and you use the same iTunes account as you originally used to buy them, then you should be able to re-download them for free : http://support.apple.com/kb/HT2519

  • Hi i'm trying to install updates but Name and then the password I have for the account won't let me in. Is my name my email address?

    hi i'm trying to install updates but Name and then the password I have for the account won't let me in. Is my name my email address?

    Updates do not normally require any kind of password access.  It is more likely your machine's security is asking for you to allow things to be updated.

  • Itunes will not load on my ipad. Icon is there. When I open "Music", it shows itunes with no content briefly and then takes me back to home page. What to do?

    itunes will not load on my ipad. Icon is there. When I open "Music", it shows itunes with no content briefly and then takes me back to home page. What to do?

    Quit the app and restart.
    Go to the home screen first by tapping the home button. Double tap the home button and the task bar will appear with all of your recent/open apps displayed at the bottom. Tap and hold down on any app icon until it begins to wiggle. Tap the minus sign in the upper left corner of the app that you want to close. Restart the iPad.
    Restart the iPad by holding down on the sleep button until the red slider appears and then slide to shut off. To power up hold the sleep button until the Apple logo appears and let go of the button.
    Or reset the iPad.
    Reset the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons.

  • Image size changes after saving and then reopening

    I'm using CS6. For example I change the image size to a 4X6 and then save it. Then when I open the file it will be 7.5X5. What's the fix? Thanks for your time.

    I'm using Photoshop CS6 on a Windows 7 - 64 bit system. I'm using the Image Size dialog box and saving the file as a 4X6 at 300 dpi from a psd file to a jpeg file. When I open the file it is 5X7.5 inches at 240 dpi. I've been playing with it and have just figured out that when I save the file as a psd file it stays the size I've created and it changes when I save as a jpeg file. This is change is recent. It's worked properly in the past. Thanks for your help.
    Steve

Maybe you are looking for

  • Apple ID email address already in use

    Whenver I try to make an Apple ID account with my main email (Hotmail), it always says that the email address is already in use. I am currently using my Gmail address as my Apple ID. I've tried recovering my Apple ID through security questions but it

  • How do I open and use a large table from Word in Pages?

    I upgraded my MBP from Snow Leopard to Mountain Lion a couple days ago.  I knew that my old Word application wouldn't work, but several Apple people assured me that Pages could handle my old docs, including tables. So, I purchased and installed Pages

  • How do you limit the amount of digits in a text field?

    If a user was to input 9 digits into a text field. How do you make it so that an error message would appear if the user inputs more than 9 digits

  • Transferring data in RDI file

    Hi, In the Payment Run how can the data be transferred to RDI file. Will it be a part of standard SAP functionality once we select RDI as format in SAPscript Output or we need to make changes in any function module to transfer the required data in RD

  • No wireless connection WRT542G

    Didn't have any internet connection at first. Configured my modem now I have internet on desktop but no wirless for laptop. Did I miss a step?