$(document).ready(SetupButtonClicks());
function SetupButtonClicks() {
$('#btnJavaPHP').click(DoPHPStuff());
}
function DoPHPStuff() {
//stuff
}
I have this code in my javascript file, when I debug it I see it call SetupButtonClicks() like it should but after that is done it calls DoPHPStuff(). DoPHPStuff() should only be called when btnJavaPHP is clicked. What am I doing wrong?
Change your SetupButtonClicks function:
The way you’ve got it coded, you’re telling Javascript to call the function, not to use it as the “click” handler. The parentheses are an operator that causes a function to be called.