How to combine 2 jquery scripts

How to combine 2 jquery scripts

I have one jquery function that submits data via a datastring to my server. This works great. On success, I currently have a little alert box that lets the user know that the data was stored. Of course, this alert box isn't tied to a server response so it isn't accurate.

I now have a second function that gets back a json response for a success or failure from the server and will echo to the user whether the data was saved successfully or not. This function should replace the alert box in the bottom most function.

I don't quite know how these two functions should fit together. Independantly, they work great but when I try and combine them, nothing works.

I'd sure appriciate any help on this. Thanks.

Here are the functions that I want to combine.

$('#Cust').submit(function() {
    var data = $(this).serialize();
    var url = $(this).attr('action');
    var method = $(this).attr('method');
    $.ajax({
        url: url,
        type: method,
        data: data,
        dataType: 'json',
        success: function(data) {
            var $div = $('<div>').attr('id', 'message').html(data.message);
            if(data.success == 0) {
                $div.addClass('error');
            } else {
                $div.addClass('success');
            }
            $('body').append($div);
        }
    });
    return false;
});



$(function() {
  $('.error').hide();
  $(".CustBtn").click(function() {
    $('.error').hide();
      var Phone = $("input#Phone").val();
        var dataString = '&Summ='+ Summ + '&Dtl='+ Dtl;
        $.ajax({
      type: "POST",
      url: "index.php",
      data: dataString,
      success: function(){
        $('#Cust input[type=text]').val('');
        alert( "Success! Data Saved");
      }
     });
    return false;
    });
});