In a php file i have used include to include the following js.php file
and prior to that i have included the jquery file.
I faced a similar problem too and this is what I did.
Ensure that document.ready is placed after the callback function is defined in your javascript file.
Here, init is not defined yet when document.ready is being parsed.
//won't work
$(document).ready(init);
var init = function() {
console.log('init not called');
}
Correct method:
//Works
var init = function() {
console.log('document is ready');
}
$(document).ready(init);
Notice that $(document).ready(init) is placed at the end.