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();
3
  • 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. Commented Apr 7, 2014 at 13:30
  • Or this other answer: NETWORK_ERROR: XMLHttpRequest Exception 101 Commented Apr 7, 2014 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! Commented Apr 8, 2014 at 7:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.