This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Building Blockchain Apps and have Michael Yuan on-line!
See this thread for details.
Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

Ajax with Chunked Transfer-Encoding

 
Saloon Keeper
Posts: 3027
418
Android Eclipse IDE Angular Framework MySQL Database TypeScript Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having a problem where JavaScript on the client side is making an asynchronous Ajax GET call to the server to receive some information in JSON format, and when the Ajax call completes, the JavaScript sees no content return, and does not display anything in the HTML table. If I type the same URL into the browsers URL box, I do see the raw JSON formatted content

I am pretty sure it has to do with the server side using chunked transfer (Transfer-Encoding: chunked rather than Content-Length: XXX), and that the Ajax implementation in jQuery not dealing with it properly. Has anyone else run into this and have a fix/work-around?


Server Side:
JBoss AS 7.1.3Final
JAX-RS using RESTEasy implementation
Web Server using Apache Tomcat implementation

Client Side:
Google Chrome VersiĆ³n 34.0.1847.131 m
jQuery 1.10.2


JAX-RS Application

JAX-RS Resource


HTML page


JavaScript with Ajax Call


Network Trace
GET /RegistrarUI/users/contacts HTTP/1.1
Host: 192.168.100.136:8080
Connection: keep-alive
Cache-Control: max-age=0
Accept: application/json, text/javascript, */*; q=0.01
X-User-Agent: javascript
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36
Referer: http://192.168.100.136:8080/RegistrarUI/contacts.html
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-GB,en;q=0.8,en-US;q=0.6,es;q=0.4,fr;q=0.2,ja;q=0.2


HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: application/json
Transfer-Encoding: chunked
Date: Wed, 07 May 2014 23:50:00 GMT

[{"username":"200","contactUri":"sip:200@192.168.100.143:58041","expiresSeconds":50},{"username":"110","contactUri":"sip:110@192.168.100.125:5090;rinstance=48786377cbc1fd43;transport=udp","expiresSeconds":25}]
 
Ron McLeod
Saloon Keeper
Posts: 3027
418
Android Eclipse IDE Angular Framework MySQL Database TypeScript Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arrrrrg - its always the simplest things that consume the most time.

I found my problem - in the HTML file. The id for the table is contacts, but I was trying to add rows to a table with an id of contacts-table.
 
I am not a spy. Definitely. Definitely not a spy. Not me. No way. But this tiny ad ...
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!