I have a javascript function, tied to a submit on a form. When I click the link, the page reloads and the function does not run. I'm not sure what might cause this or if it's typical error behaviour.
The code for the javascript is being generated dynamically by another ajax call, but I don't think that should matter, as the code is on the page. But it isn't executing.
(Here's the scenario in case context might explain what's happening: In a list开发者_StackOverflow社区, each item has a show options link. click 'show options' -> runs showoptions ajax function and generates div contents, which include link to addoption, which runs addoption ajax function (which in turn should re-run showoptions to refresh the list, but I can't get it to go that far. It breaks when I click 'add option'.)
There are two obvious possibilities:
- An error in your JavaScript (paste the JS into the JavaScript box at JS Fiddle and click the 'JS Lint' button to check), or
- You're missing a
return false
(orevent.preventSefault
) from your click-handling function.
Edited to correct my typo. Oops.
Your function probably errors out, resulting in the form's default behaviour triggering.
Check out the error console - you should get some more details there.
精彩评论