我想使用jquery form,但在控制台中显示ajaxForm不是一个函数。已正确包含jquery.form.js文件,并将代码放置在文档准备好的函数中...
以下是脚本内容:
$("#apply-form").ajaxForm({
beforeSend: function()
{
$("#progress").show();
//clear everything
$("#bar").width('0%');
$("#message").html("");
$("#percent").html("0%");
},
uploadProgress: function(event, position, total, percentComplete)
{
$("#bar").width(percentComplete+'%');
$("#percent").html(percentComplete+'%');
},
success: function()
{
$("#bar").width('100%');
$("#percent").html('100%');
},
complete: function(response)
{
$("#message").html("<font color='green'>"+response.responseText+"</font>");
},
error: function()
{
$("#message").html("<font color='red'> ERROR: unable to upload files</font>");
}
});
以下是HTML表单:
<form id="apply-form" enctype="multipart/form-data" method="post" action="">
<table>
<tr><td>CV:</td>
<td>
<input type="file" name="cover">
</td>
</tr>
<tr><td>Cover Letter:</td>
<td>
<input type="file" name="curriculum">
</td>
</tr>
<tr>
<td colspan="2">
<div id="progress">
<div id="bar"></div>
<div id="percent">0%</div >
</div>
</td>
</tr>
<tr>
<td colspan="2">
<div id="message"></div>
</td>
</tr>
</table>
</form>
我正在使用CodeIgniter创建网站,我有一个页头模板,它包含在每个页面中。在部分,我按照以下顺序包含了所有脚本:
<script src="/jobs/public/js/jquery.js"></script>
<script src="/jobs/public/js/jquery.form.js"></script>
<script src="/jobs/public/js/javascript.js"></script>
<link href="/jobs/public/js/jquery-ui-1.10.3.custom/css/custom-theme/jquery-ui-1.10.3.custom.css" rel="stylesheet">
<script src="/jobs/public/js/jquery-ui-1.10.3.custom/js/jquery-1.9.1.js"></script>
<script src="/jobs/public/js/jquery-ui-1.10.3.custom/js/jquery-ui-1.10.3.custom.js"></script>
我也在使用jQuery UI,这可能是问题的原因吗?
ajaxForm
库,您可以在Chrome的网络选项卡中找到它,或查看检查器的控制台。 - Jai