开发者

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">
    
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜