JQuery AJAX requests a response, but no callbacks start

I have code as such:

$.ajax({
     method: "GET",
     url: page,
     dataType: 'html',
     data:data,
     success: function(data){
        console.log(data);
     },
     error: function(){
        console.log('error');
     }
 });

Using the Chrome or Firefox debugger, I see that the request is successful with a 200 OK response, and the response contains the expected data. My problem, however, is that no callbacks work. "Success" does not work and not "Error". In addition, no pending methods work, for example, “done,” “then,” or “always.”

I have been trying to solve this problem for the past few hours to no avail. I have a complete loss. I also tried using methods like "$ .get" with the same result.

In short, I get a response, but the code in jQuery does not start any callbacks and all without visible errors in the console.

+4
2

:

method: "GET",

:

type: "GET",

method jQuery. type "GET", , .


, , error , ajax ( ). jQuery error:

script JSONP.

, jQuery , javascript, , , jQuery , .

, , .


, , , :

  • , / ajax- . , , www., .
  • URL ajax http https.
  • , , URL ajax .
+1

. , AJAX . , "errorThrown"

<script>
    $(document).ready(function () {
        $('#getLink').on("click", function () {
            var url = $("#myUrl");
            alert(url.val());
            $.ajax({

                type: "GET",
                url: url.val(),
                dataType: 'html',
                success: function (data, textStatus, xhr) {
                    $("#data").text(textStatus);
                },
                error: function (data,textStatus, errorThrown){
                    $("#data").text(errorThrown);
                }
            });
        });

    });

</script>

<input id="myUrl" name="myURL" type="text" value="http://localhost:35460/Home/TestPage.cshtml" />
<input type="button" value="getLink" id="getLink">
<span id="data"></span>
0

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


All Articles