| Author |
AJAX response to a Restful Jersey Resource
|
Trilochan Bharadwaj
Ranch Hand
Joined: Feb 02, 2009
Posts: 100
|
|
Hi,
I have an AJAX client which retrieves a simple string literal (at least tries to) response from a Restful Resource on the server, using a simple Java Client I can see the response OK and do anything with it; But when I use AJAX to retrieve response, the status comes as 0 for XMLHttpRequest Object, despite the fact that readyState value is set to 4. Below is my JS client code:
My Restful resource uses Jersey RS implementation, Here's the code for my Resource:
I built a TestNG test case for the same, using simple client code:
^^ The above java code gives response : 200 ... But in case of AJAX client, I get blank response text, When i check status value it is set to '0', but readyState = 4. Please note that I have to use Native AJAX stuff for this, cannot rely on any third party libraries to make AJAX calls (JQuery, Prototype, Dojo et. al.) unfortunately
Any pointers as to where I am doing something wrong?
Trilochan.
Addendum : In case of an AJAX request,
prints on the server, which means the request goes through ... but no response
|
 |
Gregg Bolinger
Ranch Hand
Joined: Jul 11, 2001
Posts: 15230
|
|
Wow, that JavaScript code looks scary. Having no clue about what library you are using there, it's going to be difficult to decipher and debug. On a side but related note, your entire JavaScript code could be condensed to the following using JQuery:
Isn't that super cool?
|
 |
Trilochan Bharadwaj
Ranch Hand
Joined: Feb 02, 2009
Posts: 100
|
|
Hey Greg,
Thanks for your reply. OK, maybe I over did my log thingie it just helps me debug on firebug better. If you read my entire post though, at the end, I do mention that I can't use, JQuery, Dojo, Prototype, DWR, Moo Tools ... well you get the picture ;)
I understand that there are frameworks that do this kinda thing and condense the code into few lines ...
Trilochan.
Addendum: This is not any third party library, it forms part of an open source framework that I am building and working on, here's the link:
HCIS framework
|
 |
 |
|
|
subject: AJAX response to a Restful Jersey Resource
|
|
|