NaveenDAlmeida
NaveenDAlmeida

Reputation: 1261

Add JavaScript to js file from external html page using jquery

$.ajax({   
    url: "sub_template5_js.php?content_id="+content_id,  
    dataType: 'html',
    success: function(data){  
        alert(data);
    }  
});

In above code, when i give alert data i get html with js script, i need to separate the javascript and append to the external .js file Pl. Help me

Thank you

Upvotes: 0

Views: 117

Answers (1)

bipen
bipen

Reputation: 36531

using script as selector should work..

$('script').text(); // use attribute selector to get a particular one .   

fiddle here

note: have to use loop , if incase you have more than one script tag.

this is just an example to get you started...

havn't tested with youe data part but you can try..

 data.find('script').text();

Upvotes: 1

Related Questions