call .js file after ajax load
Posted
by
asovgir
on Stack Overflow
See other posts from Stack Overflow
or by asovgir
Published on 2012-11-11T04:54:13Z
Indexed on
2012/11/11
5:00 UTC
Read the original article
Hit count: 209
I am trying to apply a .js file to a page I loaded via ajax (since ajax automatically strips the content of all the javascript).
var url;
var textUrl = 'local/file.js';
$('a').click(function() {
url = $(this).attr('href');
$('.secondaryDiv').load(url, function() {
$.getScript(textUrl, function(data, textStatus, jqxhr) {
console.log(data); //data returned from getScript
console.log(textStatus); //return "success"
console.log(jqxhr.status); //200
});
});
return false;
});
Am I approaching this the right way? I tried everything I could think of and I can't get it to work
© Stack Overflow or respective owner