Reputation: 263
This jQuery ajax request is not working. The form submit just reloads the page, there are no alerts, nothing. Where am I going wrong?
$("#newfolder").submit(function() {
alert("1")
$.ajax({
type : "POST",
url : "<?php echo $cfg->wwwroot ?>/pages/media/async/newfolder.php",
data : $(this).serializeArray(),
success: function(data) {
alert(data)
//$.fancybox(data);
}
});
return false;
});
Upvotes: 0
Views: 457
Reputation: 1108742
This can have several causes.
Ensure that you've included jQuery as one of first <script>
s in HTML <head>
.
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
Ensure that you're calling this function when the document is ready loading.
<script>
$(document).ready(function() {
// Here.
});
</script>
Ensure that the element with id="newFolder"
is present in HTML DOM tree and supports the submit
event.
<form id="newFolder">
Upvotes: 4