Executing [removed] injected by innerHTML after AJAX call

前端 未结 11 1719
误落风尘
误落风尘 2020-11-22 05:02

There\'s a div called \"Content\":

It should be filled with data from a PHP file, by AJAX, including

11条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-22 05:22

    This worked for me by calling eval on each script content from ajax .done :

    $.ajax({}).done(function (data) {      
        $('div#content script').each(function (index, element) { eval(element.innerHTML); 
    })  
    

    Note: I didn't write parameters to $.ajax which you have to adjust according to your ajax.

提交回复
热议问题