I have a script that works completely fine on static web page, but I cannot get it to work on dynamic web pages. I tried different techniques from the research I've done, but I still cannot get it to work, so I'm looking for help.
My script:
<script type="text/javascript" src="http://mywebsite.com/js/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(document).on('submit', '#bv-form', function() {
var data = $(this).serialize();
$.ajax({
type: 'POST',
url: 'notify.php',
data: data,
success: function(data) {
$("#bv-form").fadeOut(500).hide(function() {
$(".form-result").fadeIn(500).show(function() {
$(".form-result").html(data);
});
});
}
});
return false;
});
});
Form:
<form method="post" id="bv-form">
<div class="checkbox form-feedback margin-five m_top_20">
<!-- checkbox -->
<label><input type="checkbox" name="video_title" id="publish" checked value="<?php echo ucwords($row['video_title']); ?>"> <em>"<?php echo ucwords($row['video_title']); ?>"</em> by <b><?php echo ucwords($row['artist_name']); ?></b> is not working</label>
<!-- end checkbox -->
</div>
<div class="form-group">
<!-- button -->
<button class="btn btn-black no-margin-bottom btn-small no-margin-top" id="submit" type="submit">Send</button>
<!-- end button -->
<input type="hidden" id="id">
<input type="hidden" id="video_id" name="video_id" value="<?php echo ucwords($row['id']); ?>">
<input type="hidden" id="artist_name" name="artist_name" value="<?php echo $row['video_title']; ?>">
</div>
</form>
I'm using .on(), but is there something I'm missing?
NOTE: I know that the question has been asked before on this site. I've tried following certain steps in those solutions, but I still cannot get this script to work.
$('#bv-from').lengthbefore running your script, might narrow down the problem