So I am using an AJAX loader on my WP installation and one of the pages I am loading has a script in it.
<div id="register-form">
<div id="register-one"></div>
<div style="text-align:center;padding-top:10px;"></div>
<div class="horizontal-rule"></div>
<div id='register'>
<div id="register-character">
</div>
</div>
<div class="post">
<form action="" method="post" id="register-form" >
What's your Name:
<input class=in id='register_name' name="register_name" onkeydown='register_step1_keydown();' onkeyup='register_step1_keyup();'>
<input class="next-submit-button" type="submit" id="register-step-one" value="" />
<input type="hidden" name="submit" />
</form>
</div>
</div>
<script type="text/javascript">
$("#register-step-one").click(function() {
$.ajax({
type: "POST",
success: function() {
$('#register-form').html("Test");
}
});
return false;
});
</script>
The issue is however, when the page is loaded through the AJAX, the script doesn't work. Yet if I refresh the page the script works. Obviously the script doesn't like running from an AJAX call.
Is there a way to make the script work when it is loaded through an AJAX call? I know I could put the script in to the main page's footer or something but I was hoping I could get around this as I will end up with a ton of scripts in the main page.