我有以下代码(工作正常),我想将其更改为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;});
这是我写的ajaxForm():
$(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); });
来自ajaxForm的帖子数据很奇怪......我的php代码无法从中收到任何内容,除了文件上传现在有效。