Jquery: why does $ .get send an OPTION package?

$.get('http://localhost/a.bb?cmd=<abc></abc>', function(data) {
   alert('result comes back.');
   $('.result').html(data);
  });
);

Above is the code I want to send to the server, why does jquery send OPTION to me? I want to use the GET method.

Thank.

+3
source share
2 answers

jQuery / webbrowser will send an HTTPOPTIONS request whenever the URL belongs to a different domain than the one from which this page was created and jQuery dataTypedoesn’t JSONP. Upon request, the OPTIONSserver should return a Allowheader with all the HTTP methods that are allowed to be used. For instance. GET,POST. Then the web browser will continue the actual XMLHttpRequest.

.

+9

, , , ,

$.get('http://localhost/a.bb',{"cmd":"<abc></abc>"}, function(data) {
        alert('result comes back.');
        $('.result').html(data);
    });
);
+1

Source: https://habr.com/ru/post/1770324/


All Articles