PHP jQuery ajax request is not responding
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;
});
开发者_运维问答
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 thesubmit
event.<form id="newFolder">
精彩评论