jQuery ajax完成循环

I have a code:

$(document).ajaxComplete(function() {
  DoSomething();
});

function DoSomething() {
 ...
 $.get(MyUrl, function() {
   ...
 });
 ...
}

But $.get cyclnig ajaxComplete event :(

Exist some way, how to get HTML content from my URL into variable to work with this variable (find class and content) or some way, how to disable ajaxComplete event ONLY for the proccess with $.get ?

You can check the URL of the request inside the ajaxComplete. If it's the URL you requested in DoSomething, don't call DoSomething again:

$(document).ajaxComplete(function(_, __, { url }) {
  if (url === 'https://jsonplaceholder.typicode.com/posts/1') {
    console.log("Recursion detected, don't do anything");
  } else {
    console.log('Calling DoSomething');
    DoSomething();
  }
});

function DoSomething() {
 $.get('https://jsonplaceholder.typicode.com/posts/1', function() {
   console.log('DoSomething done');
 });
}

$.get('https://jsonplaceholder.typicode.com/posts/5');
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

You can also set a property on the options object you pass to $.get, and check for the existence of that property in the .ajaxComplete:

$(document).ajaxComplete(function(_, __, { fromDoSomething }) {
  if (fromDoSomething) {
    console.log("Recursion detected, don't do anything");
  } else {
    console.log('Calling DoSomething');
    DoSomething();
  }
});

function DoSomething() {
 $.get({
   url: 'https://jsonplaceholder.typicode.com/posts/1',
   fromDoSomething: true
 }, function() {
   console.log('DoSomething done');
 });
}

$.get('https://jsonplaceholder.typicode.com/posts/5');
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

</div>