• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Prototype Ajax.Request onSuccess callback is called immediately

 
Ranch Hand
Posts: 94
Eclipse IDE C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am issuing an Ajax.Request() to a Struts 2 action, which is actually getting through to the execute() method. But the onSuccess callback function is being executed immediately, returning with a status of ZERO '0'. Does anyone have any ideas on why the callback is being called immediately?

I know that the action is not completed before the onSuccess callback, because I have a breakpoint set in the action's execute() method.
 
author
Posts: 15385
6
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is your code?

See my answer in this thread on why you get zero https://coderanch.com/t/517225/HTML-JavaScript/ajax-status-code#2341566

Eric
 
Robert Heath
Ranch Hand
Posts: 94
Eclipse IDE C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Eric Pascarello wrote:What is your code?

See my answer in this thread on why you get zero https://coderanch.com/t/517225/HTML-JavaScript/ajax-status-code#2341566

Eric



The response is:

Eric Pascarello wrote:
Status zero happens when

1) Page is being served from file protocol
2) Page exits/refreshes as an active XMLHttpRequest is still being processed. It throws an "INVALID_STATE_ERR " error and sets the status to zero.

Cancel the link/button click and you should be good to go.



Eric,

Do you know if my request is being satisfied by the localhost:8080, is that from the file protocol? I am using TomCat as an application server on my machine.

Thanks - Bob
 
Robert Heath
Ranch Hand
Posts: 94
Eclipse IDE C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eric,

I called the event stop method, and that seems to have fixed the problem

Thanks for your help!

Bob
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Robert Heath wrote:

Eric Pascarello wrote:
Do you know if my request is being satisfied by the localhost:8080, is that from the file protocol? I am using TomCat as an application server on my machine.



Means you would be running from the c drive directly and not serving it up with a server.


Robert Heath wrote:Eric,

I called the event stop method, and that seems to have fixed the problem

Thanks for your help!

Bob



So that means your button was causing the page to submit and you stopped the default action from happening.

Eric

 
reply
    Bookmark Topic Watch Topic
  • New Topic