PDA

View Full Version : QtWebKit not able to execute $.post properly; json data missing on server side



mimic
12th June 2014, 13:37
Good day,

the following js code:


var xmlfn = "file.xml";
var json = "{\"command\":\"read\",\"fn\":\""+xmlfn+"\"}\n";
var jqxhr = $.post(
"http:127.0.0.1:" + port,
json,
this.postSuccessHandler,
'text'
);

is not able to properly send the data section (json string) to the server side.
When using the Firefox/Chrome browser, the server output is:


"Host: 127.0.0.1:8080"
"Connection: keep-alive"
"Content-Length: 41"
"Accept: text/plain, */*; q=0.01"
"Origin: http://127.0.0.1:8080"
"User-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/34.0.1847.116 Chrome/34.0.1847.116 Safari/537.36"
"Content-Type: application/x-www-form-urlencoded; charset=UTF-8"
"Referer: http://127.0.0.1:8080/"
"Accept-Encoding: gzip,deflate,sdch"
"Accept-Language: en-US,en;q=0.8,ja;q=0.6,de;q=0.4,pl;q=0.2"
""
"{"command":"read","fn":"file.xml"}
"

but when I use the QWebView, the json part is missing (the socket reads two empty lines after the header).

The only clue I have found until now is that when I add
alert(json); to the js code, then Firefox/Chrome prints
{"command":"read","fn":"file.xml"}
whereas QWebView brings
{"command":"read","fn":"file.xml"}

Any ideas on how to make QtWebKit/QWebView send the json data to the server component?

Cheers