I am trying to invoke an asynchronous restful web service from jquery. The problem is that the HTTP client does not refresh when receiving the result, I have to refresh the browser manually. This is the jquery code I am using:
G Peruana wrote:Shouldnt it get updated without the need to refresh?
What is "it"? If you are asking about the HTML fragment that will be inserted in the DOM, then yes, no need to refresh. but you are not being at all clear about what you are trying to do, and what's going awry.
The code might have some minor error because I tried to delete all comments and not relevant code.
That's not going to cut it. When that happens, everyone spends time looking at the bogus errors instead of the real problem. When posting code, please be sure to post an SSCCE (⇐ that's a link) that demonstrates the problem.
Let me give you the complete code and further explanation:
I am trying to fulfill an invocation from jquery to an Asynchronous service (just following the asynchronous example fro jersey tutorial). I give below the two examples I tried (simple one and with callvback) and explain the results an errors. Any help with any of the examples is welcomed, I am just trying to guess what I am doing wrong.
In the service side I have the following code:
In the client side I have the following one
If I execute the html web I get the 'asy' alert (therefore asyncGet is being invoked) but I do not get any result in data.
If I add the empty return that is now commented in asyncGet (I read it in some forums) , I get the following error "SEVERE: Error while closing the output stream in order to commit response.
Using the same client code, what I get is
1) Currently alert asy is shown and in the server console "throwable" is shown; therefore the asyncGetWithCallback is being invoked. But still I do not get the data in the client.
2) From time to time if I test in a different browser window I get only the data (WORKING)
The thing is, when no error is launched, the data returned is simply empty. This is why (I guess) it is an async method and the resume method is not reaching the way back. Something in the way I am implementing the callback is wrong. I looked over other forums and found more people having trouble for making this jersey example work and no solutions yet.
When error is launched (ONLY SOMETIMES) I get the following in Eclipse console
I was not coming to this thread on purpose. Just by accident.
So this is JAX-rs 2.0 and new to me. But there is a JAX-RS 2.0 client api.
Since you have JAX-rs 2.0 on server. Why don't you try to test the use case with JAX-rs 2.o client api.
This is to ensure you get what you expected. Java-to-java end-to-end. Once you're sure the server code is OK.
Then test the server code with various client code which is jquery in your case or any language.
This looks like a job for .... legal tender! It says so right in this tiny ad: