Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Calculator

0

79
Views
AJAX call : JQuery ok but Vue and Vanilla JS not executing script inside element

I would like to execute a code inside an html element after an xhr request

I used to used JQUERY $(el).html(data) and that worked just fine

Now trying to get rid of jquery

I tried both vanilla JS innerHTML and vue3 v-html but the script never executes

I can see it in html

enter image description here

Here is the code:

    axios.get('/getAarea/blog')
        .then(response => {
          const data = response.data;
          if (!data.report) {
            const el = $("#ContentUserPanel")
            el.html(data)
            this.loading = false
            this.selected = this.types.blogs
            this.toggleUserMobileMenu()
          } else {
            Error('There was an error ',data.report)
            this.loading = false
            this.selected = null
          }
        })
        .catch(err => {
          Error('There was an error ',err)
          this.loading = false
          this.selected = null
        });

Could someone explain ?

7 months ago ยท Juan Pablo Isaza
Answer question
Find remote jobs