Php jqueryajax表单上传
下面是一个简单的ajax提交表单示例:Php jqueryajax表单上传,php,jquery,forms,upload,Php,Jquery,Forms,Upload,下面是一个简单的ajax提交表单示例: $('#submit').click(function () { var myName = $('#name').val(); var myContent = $('#content').val(); // ajax $.ajax({ type: 'post', url: '/ajax.process.php', data: { post_name:
$('#submit').click(function () {
var myName = $('#name').val();
var myContent = $('#content').val();
// ajax
$.ajax({
type: 'post',
url: '/ajax.process.php',
data: {
post_name: myName,
post_content: myContent
},
dataType: 'json',
success: function (data) {
if (data.status.OK == 'OK') {
console.log('OK');
return false;
} else {
console.log('ERROR');
return false;
}
}
}); // end ajax
});
这是我的html:
<form method='post' enctype='multipart/form-data' action='ajax.process.php' id='form-main'>
<textarea cols='50' rows='5' id='content' name='post_content'></textarea>
<input type='text' id='name' class=' name='post_name'>
<input type='file' id='attach' name='attach'/>
<input type='button' value='Submit' id='express-form-submit'>
</form>
jquery无法发布这些文件,因为您无法访问它们的内容。另外,您不发布表单,而是使用jquery执行单独的ajax请求。是否可能重复?你能再具体一点吗D