Search code examples
javascriptphpajaxdynamicgetscript

PHP generated Javascript load via AJAX possible?


I need to load a dynamic created javascript with PHP. Is there any good solution to load javascript creating by PHP after some ajax requests finished?

Thx in regards, i am searching for 2h in stackoverflow.

if i call .ajax function where html/js respone, jquery kills the js ;/


Solution

  • jQuery.ajax({
        type: 'POST',
        dataType: 'html',
        url: $url,
        success: function(result)
          { 
             result // html
    
             jQuery.ajax({
         type: 'GET',
         dataType: 'script',
             url: $url,
             success: function(result)
                { 
                //the result is js and is availble in browser if you return 
                //a function you can execute this now
    
                }
              });
    
          }
    });
    

    Hope someone find his answer here :) gl & hf & nice day