【发布时间】:2016-03-11 17:37:05
【问题描述】:
我正在尝试使用 codeigniter 以及如何在控制器中接收通过 ajax 将图像上传到某个位置。
我搜索太多但不知道问题出在哪里!
Ajax 代码:
$('#btnform2').click(function(e){
e.preventDefault();
// valadation_form();
$("form#data").submit(function(event){
//disable the default form submission
event.preventDefault();
//grab all form data
var formData = new FormData($(this)[0]);
$.ajax({
url: '<?php echo base_url(); ?>"+"index.php/club/post_ajax',
type: 'POST',
data: formData,
async: false,
cache: false,
contentType: false,
processData: false,
success: function (returndata) {
alert(returndata);
}
});
return false;
alert("test");
});
});
我的表单
<form method="post" class="form-horizontal" id="form_members" role="form" name="uploader">
<label for="fullname" class="col-sm-2">Full Name</label>
<input type="text" class="form-control" name="fullname" id="firstname" placeholder="Full Name" >
<label for="lastname" class="col-sm-2">Computer Number</label>
<input type="text" class="form-control" name="computernumber" id="lastname" placeholder="Computer Number">
<label for="address" class="col-sm-2">E- mail Address</label>
<input type="email" class="form-control" name="email" id="address" placeholder="Email Address">
<label for="city" class="col-sm-2">Mobile Number</label>
<input type="text" class="form-control" list="cities" name="mobilenumber" id="mobilenumber" placeholder="Mobile Number">
<label for="phone" class="col-sm-2">Nationality</label>
<input type="tel" class="form-control" name="Nationality" id="nationality" placeholder="nationality">
<label for="email" class="col-sm-2">Upload Photo</label>
<input id="file" class="file" type="file" multiple data-min-file-count="1">
<button name="submit" class="btn btn-warning" id="btnform2">Update Player Profile</button>
</form>
【问题讨论】:
-
你知道你的问题是你不知道如何调试,首先控制台说什么?
-
如果我使用 alert 它不会显示错误,它会提醒消息但 ajax 没有调用
标签: php jquery html ajax codeigniter