Can't submit data using jQuery form plugin

I have the following code (works great) that I want to change in the jQuery Form Plugin ajaxForm ():

$("#replysubmit").click(function() {
    var msg = $("#message").val();
    var attach = $("#attach").val();
    var id = $("input[name=hidden-ticketID]").val();
    if(msg == "") {
            alert("not null");
            $("#message").focus();
            return false;
        }
    $.ajax({
        type: 'POST',
        dataType: 'json',
        url: '/TicketSystem/support/view',
        async: false,
        data: {id: id, msg: msg, attach: attach},
        success: function(json) {
            $.post('/TicketSystem/support/ajaxmsg', { date: json.date, msg: json.msg }, 
            function(data){
                var newData = $('<div>').addClass('msgBlock').html(data).hide();
                newData.appendTo($('.msgWrapper')).slideDown('normal');
                goToByScroll('reply-form');
            });
            $("#message").val('');
            $("#attach").val('');
        }
    });
    return false;});

      

and this is the ajaxForm () I wrote:

$(document).ready(function() { 
var msg = $("#message").val();
var attach = $("#attach").val();
var id = $("input[name=hidden-ticketID]").val();
var options = { 
    //target:        '#output1',   // target element(s) to be updated with server response 
    beforeSubmit:  showRequest,  // pre-submit callback 
    success:       showResponse,  // post-submit callback 

    // other available options: 
    url: '/TicketSystem/support/view',
    type: 'POST',
    dataType: 'json',
    data: {id: id, msg: msg, attach: attach},
    //clearForm: true        // clear all form fields after successful submit 
    //resetForm: true        // reset the form after successful submit 

    // $.ajax options can be used here too, for example: 
    //timeout:   3000 
}; 

// bind form using 'ajaxForm' 
$('#user-reply-form').ajaxForm(options); }); 

      

Post data from ajaxForm wierd ... and my PHP code couldn't get anything from it other than that the file is being loaded now.

+3


source to share





All Articles