Skip to content Skip to sidebar Skip to footer

Jquery Ajax And Java Server, Lost Data

i have this ajax function that looks like so $.ajax({ type: 'POST', url: 'http://localhost:55556', data: 'lots

Solution 1:

The data should come after a blank line after the header lines, but I think the problem is that the data does not end with a newline character, and therefore, you cannot read it with the .readLine() method.

While looping through the header lines, you could look for the "Content-Length" line and get the length of the data. When you have reached the blank line, stop using .readLine(). Instead switch to reading one character at a time, reading the number of characters specified by the "Content-Length" header. I think you can find example code for this in this answer.

If you can, I suggest you use a library to help with this. I think the Apache HTTP Core library can help with this. See this answer.

Post a Comment for "Jquery Ajax And Java Server, Lost Data"