0

I need to send request to server in sync mode, so i set async=false, but i receive always NETWORK_ERR: XMLHttpRequest Exception 101. Here is my code, there i someone that know how can i improve it to fix this issue?

var request = new XMLHttpRequest();
request.open("GET", 'ip-address ', false);
request.onreadystatechange = function () {
    if (request.readyState == 4) {
        if (request.status == 200 || request.status == 0) {
            var data = JSON.parse(request.responseText);
            var object = "";
            var string = "";
            var find = false;
            window.localStorage.setItem(data.id, JSON.stringify(data));
            $.each(data.img, function (i, item) {
                if (data.img[i].principal) {
                    string = data.img[i].path;

                }

            });
            if (string == "") string = data.img[0].path;
            var splitt = string.substring(2);
            window.localStorage.setItem("img" + data.id, splitt);
            if ($("#img" + (l + 1)).attr("src") === 'ip-address' + splitt) {
                find = true;
            } else {



                object='<img id="img'+(l+1)+'" src="ip-address'+splitt+'" name="'+data.id+'"></img>';                if (!trovata) {
                    if (flag) {
                        $("#" + (l + 1)).empty();
                        $("#" + (l + 1)).html(object);
                        if (l == 0) {
                            $("#" + (l + 1)).flip({
                                direction: 'tb'
                            });
                        } else {
                            switch (l % 2) {
                            case (1):
                                $("#" + (l + 1)).flip({
                                    direction: 'lr'
                                });
                                break;
                            case (0):
                                $("# " + (l + 1)).flip({
                                    direction: 'rl'
                                });
                                break;
                            }

                        }
                    }
                }
            }
        }
    }
    request.send();
CarloM_dtb
  • 21
  • 2
  • 9
  • I don't know if this is the same issue you are having but sounds like it; Take a look at [NETWORK_ERR: XmlHttpRequest Exception 101 in Android](http://stackoverflow.com/questions/14661210/network-err-xmlhttprequest-exception-101-in-android). – FMontano Apr 07 '14 at 13:30
  • Or this other answer: [NETWORK_ERROR: XMLHttpRequest Exception 101](http://stackoverflow.com/questions/2235929/network-error-xmlhttprequest-exception-101) – FMontano Apr 07 '14 at 13:37
  • No, thanks, i've already readed that but it doesn't work for me. The permission are ok, because the app works good one time and give back error another time. It's so strange! – CarloM_dtb Apr 08 '14 at 07:05

0 Answers0