[webkit-qt] ajax returns json with "

Sylvain Pointeau sylvain.pointeau at gmail.com
Wed Aug 24 01:15:06 PDT 2011


Hi Ademar,

I found what was the issue.
first I discovered that in Jquery, I had a status = 0, that's why jquery
failed.
but why status = 0? so I went back to the small ajax code using directly
XMLHttpRequest,
and here the status was correctly 200...
[... skip few hours :-) ...]

the difference was the async = true that works
but async = false  returns status = 0.

so you can reproduce the bug with having this code, you will see the status
= 0 but it will work because we are just testing the readystate. JQuery will
fail because it tests the status.

function search() {

>  var xmlhttp= new XMLHttpRequest();
>  xmlhttp.open("GET", "test_json.json",false);
>  xmlhttp.onreadystatechange=function() {
>
                           alert( "readyState="+xmlhttp.readyState+"
status="+xmlhttp.status);

if (xmlhttp.readyState==4) {
>                                 var myjson = JSON.parse(
> xmlhttp.responseText );
> alert( myjson.message );
> }
> }
>  xmlhttp.send(null);
>


You were correct, it comes from the ajax call (async=false), nothing else.
Please could you investigate on the Qt side why async = false is failing to
return the status code?

Many thanks in advance,

Best regards,
Sylvain
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-qt/attachments/20110824/a5e070ef/attachment.html>


More information about the webkit-qt mailing list