Jump to content
MakeWebGames

Recommended Posts

Posted

Anyone know how to make this coffee not refresh the page? 

Code tags are not above me

<script>
$(document).ready(function() {

    $(function() {
     $( "#createDialog" ).dialog({
        autoOpen: false, 
              
        });
        $( "#opener" ).click(function() {
               $( "#createDialog" ).dialog( "open" );
      });

   });
         
         
    // process the form
    $('form').submit(function(event) {

        // get the form data
    var form = $('#ajaxItem');
    var post_url = $(this).attr("action");
      
        // process the form
        $.ajax({
            type        : 'POST', 
            url         : post_url,
            data        : formData,
            dataType    : 'json',
            encode          : true
        })
        return false;
        // stop the form refrshing
        event.preventDefault();
        
    });
});
</script>

 

 

  • Haha 1
Posted

Move event.preventDefault(); above return false
So this
 

// process the form
    $('form').submit(function(event) {

        // get the form data
    var form = $('#ajaxItem');
    var post_url = $(this).attr("action");
      
        // process the form
        $.ajax({
            type        : 'POST', 
            url         : post_url,
            data        : formData,
            dataType    : 'json',
            encode          : true
        })
        return false;
        // stop the form refrshing
        event.preventDefault();
        
    });

becomes this
 

// process the form
    $('form').submit(function(event) {
        // stop the form refrshing
        event.preventDefault();

        // get the form data
    var form = $('#ajaxItem');
    var post_url = $(this).attr("action");
      
        // process the form
        $.ajax({
            type        : 'POST', 
            url         : post_url,
            data        : formData,
            dataType    : 'json',
            encode          : true
        })
        return false;
        
    });

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...