0

I'm trying to debug my ajax response text however it keeps returning undefined, here's my code:

$(document).ready(function() {
  var data = $.ajax({
    type: "GET",
    url: "https://raw.githubusercontent.com/Theruler333/Letsmod/master/test.txt",
    dataType: "text"
  }).responseText;
  console.log(data);
});
Hpeachey
  • 23
  • 3

1 Answers1

1

Note that AJAX is async function. You need to wait for it.

This should work

    $(document).ready(function() {
        var data = $.ajax({
            type: "GET",
            url: "https://raw.githubusercontent.com/Theruler333/Letsmod/master/test.txt",
            dataType: "text"
        }).then(e=>{
          console.log(e);
        });
    });
tigercosmos
  • 345
  • 3
  • 17