L
L
LB7772015-04-10 10:54:59
JavaScript
LB777, 2015-04-10 10:54:59

How to get jQuery ajax working in ie8/9?

Making a cross-domain request

function AjaxFormRequest () {
            $.ajax({
                type: "POST",
                crossOrigin: true,
                dataType: "json",
                contentType: "application/json",
                url: "http://site.com/api/TestCall",
                data: '{"arg1":"sad","arg2":"tgt"}', 
                success: function (response) {
                    if (response['error']) {
                        alert("Сервер вернул ошибку: " + response['error']);
                    } else {
                        alert("Сервер вернул нечто: " + response);
                    }
                },
                error: function (jqXHR) {
                    console.log("jQuery свалился в собственный error. readyState: " + jqXHR.readyState);
                }
            });
        }


In all modern browsers it works fine, but in ie9 and below, the request to the server is not sent, but immediately gives the error "jQuery fell into its own error. readyState: 0".
In jQuery 1.5.0 and 1.5.4 the jqXHR.readyState error is returned 4 but still the request is not sent. In all other versions (before 1.11.2) you give the status 0 and the request is not sent either.
What is the problem and how to fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
v- death, 2015-12-11
@vGrabko99

jsonp for donkey

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question