Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. While Press "Esc" key ajax request and response is stopped in the browser

While Press "Esc" key ajax request and response is stopped in the browser

Scheduled Pinned Locked Moved JavaScript
helpquestion
5 Posts 2 Posters 4 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    PeriyasamyRamachandran
    wrote on last edited by
    #1

    Hi, While running my application if any error gets then, a modalbox will show with the error message, So I close the modalbox using "Esc" key. In the meantime the next ajax request and response is stopped in the browser since i pressed "Esc" key. So I want to close modalbox using "Esc" and also the next ajax request and response do not stopped by the browser?. Can anybody help me how can i handle this? Regards, Periyasamy.R

    J 1 Reply Last reply
    0
    • P PeriyasamyRamachandran

      Hi, While running my application if any error gets then, a modalbox will show with the error message, So I close the modalbox using "Esc" key. In the meantime the next ajax request and response is stopped in the browser since i pressed "Esc" key. So I want to close modalbox using "Esc" and also the next ajax request and response do not stopped by the browser?. Can anybody help me how can i handle this? Regards, Periyasamy.R

      J Offline
      J Offline
      Jules VDV
      wrote on last edited by
      #2

      Most browsers use the Escape key to cancel out of loading a page and I think it is probably also causing any other AJAX requests being processed to also be canceled by your browser. As for stopping this default behavior, you could try preventing the Esc key's default action with the following:

      //place in the window keydown event

      //IE
      e.cancelBubble=true;
      e.returnValue = false;

      //FF
      if (e.stopPropagation){
      e.stopPropagation();
      e.preventDefault();

      P 1 Reply Last reply
      0
      • J Jules VDV

        Most browsers use the Escape key to cancel out of loading a page and I think it is probably also causing any other AJAX requests being processed to also be canceled by your browser. As for stopping this default behavior, you could try preventing the Esc key's default action with the following:

        //place in the window keydown event

        //IE
        e.cancelBubble=true;
        e.returnValue = false;

        //FF
        if (e.stopPropagation){
        e.stopPropagation();
        e.preventDefault();

        P Offline
        P Offline
        PeriyasamyRamachandran
        wrote on last edited by
        #3

        Hi, Thanks for your reply. Great!. It works for me.Now the ajax request and response is not stopped when i use "Esc" or any key. Its good. Thanks, Regards, Periyasamy.R

        modified on Thursday, October 28, 2010 2:22 AM

        J 1 Reply Last reply
        0
        • P PeriyasamyRamachandran

          Hi, Thanks for your reply. Great!. It works for me.Now the ajax request and response is not stopped when i use "Esc" or any key. Its good. Thanks, Regards, Periyasamy.R

          modified on Thursday, October 28, 2010 2:22 AM

          J Offline
          J Offline
          Jules VDV
          wrote on last edited by
          #4

          Are you talking about a regular javascript modal message box or a html/css/js modalbox? If it's the latter, I would call it's close function prior to stopping the event propagation in your keydown handler.

          P 1 Reply Last reply
          0
          • J Jules VDV

            Are you talking about a regular javascript modal message box or a html/css/js modalbox? If it's the latter, I would call it's close function prior to stopping the event propagation in your keydown handler.

            P Offline
            P Offline
            PeriyasamyRamachandran
            wrote on last edited by
            #5

            Hi Jules, It works for me. Thanks for your reply. -Periyasamy.R

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups