简体   繁体   中英

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 the submit event.

     <form id="newFolder"> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM