我正在使用一些AJAX代码将表单值传递给php页面然后更新数据库,这一切都正常,但对于两个文本区域字段称为Job_description和notes。
如果我删除了Ajax代码并将表单值直接传递给php页面,它一切正常,但是通过ajax传递值,字段job_description和notes不会被传递。下面是我的代码。
$(document).ready(function(){
$('form.save').submit(function () {
var ref_number = $(this).find("[name='ref_number']").val();
var job_title = $(this).find("[name='job_title']").val();
var start_date = $(this).find("[name='start_date']").val();
var closing_date = $(this).find("[name='closing_date']").val();
var category = $(this).find("[name='category']").val();
var location = $(this).find("[name='location']").val();
var postcode = $(this).find("[name='postcode']").val();
var salary = $(this).find("[name='salary']").val();
var client = $(this).find("[name='client']").val();
var job_description = $(this).find("[name='job_description']").val();
var license = $(this).find("[name='license']").val();
var notes = $(this).find("[name='notes']").val();
// ...
$.ajax({
type: "POST",
url: "save.php",
data: {
ref_number : ref_number,
job_title : job_title,
start_date : start_date,
closing_date : closing_date,
category : category,
location : location,
postcode : postcode,
salary : salary,
client : client,
job_description : job_description,
license : license,
notes : notes,
},
success: function(){
new PNotify({
title: 'Job Posted',
text: 'Thank you, your job has now been added to the jobboard.',
type: 'success',
shadow: true
});
}
});
this.reset();
return false;
});
});
所以我没有弄清楚,由于使用了Tiny Mce,文本区域没有传递表单的值。如果我从表单中删除Tiny Mce,Ajax会完美地通过ajax传递表单值,但是一旦我添加了Tiny Mce,它就会再次停止传递文本区域的表单值