onClick functions reloads page instead of running the code inside its own brackets
I tried posting a script earlier, but it was too big to be accepted on this forum. Instead I'll ask a question, and see if I get any answers that I can use to find the problem myself.
I know its always best to post code, but I couldn't get it small enough without risking cutting out the parts that people need to see to find the problem.
I have 2 js scripts, that are part of a larger ajax script, that run on page load - I'll call them A and B. They run fine.
I have 2 scripts that I wrote inside function brackets. They run onClick - I'll call them C and D
A and B run on page load. This places a button inside an html form. That button runs C just fine onClick.
Script C places a button that is supposed to run D onClick.
Script D is written inside function brackets, and is supposed to fire onClick.
The problem is firebug (tab XHR) shows that D does not post anything to the php script it points too. I know that php script works.
Clicking on the button that is supposed to fire script D causes the onload functions, A and B to fire again. D ignores the code written inside its own brackets.
D reloads the page instead.
C does post, and works fine. It looks to me that C is written the same way as D.
I wrote in a "return false" after each button. I've also set the open method of the XMLHttpRequest Object to both true and false. Problem still there.
I wrote I object per onload script, so each script can do its own thing.
To my eye, it looks like I've written the functions C (works onClick) and D (doesn't work because it runs the 2 onload functions onClick, instead of what is written inside its own brackets) the same way.
I can't spot any syntax errors.
Does anyone know of anything that would cause this? I know browsers do their own thing when syntax errors confuse them too much.
Any suggestions of how to use firebug to further diagnose?