title: async await on Jquery ajax callback?
body: <p>I'm trying to do this with <code>async/await</code>, but any solution is good. Anyone know how I could change this:</p>
  
  <pre><code>series[group].forEach(async (ele, j) =&gt; {
      await $.ajax({
          url: `templates/ele${ele}.template.html`,
          success: function (data) {
            const $copyEl = $(el).clone()
            const r = new RegExp('\\{\\{\\s*' + item + '\\s*\\}\\}', 'g')
            const html = $copyEl.html().replace(r, data)
  
            $(html).insertBefore(parent)
          },
          error: function (e) {
            console.error(e)
          }           
        }).then(() =&gt; {
          $(parent).detach()
          if(i + 1 === outer_last &amp;&amp; j + 1=== inner_last)
            template_callback()
        })
    })
  })
  </code></pre>
  
  <p>to not run the <code>.detach()</code> until after the last <code>.insertBefore()</code> completes?</p>