【发布时间】:2014-05-13 04:18:20
【问题描述】:
我的应用程序位于 codeigniter 中,带有 smarty 模板。我想使用 ajax 提交功能提交表单,但输入类型是用于图像上传的文件,我为此使用 serialize(),但它不能给我数据...
我的 .tpl 文件代码是:
<form method="post" action="" name="form_submit7" id='form_submit7' class="form-horizontal" enctype="multipart/form-data">
<h4>Logo Uploading</h4>
<div class="booth-settings">
<div class="form-group">
<label class="col-md-4 control-label">Upload logo</label>
<div class="col-md-7">
<input type="file" name="expo_company_logo" class="form-control" placeholder="Upload Logo"><br>
</div>
<input type="submit" style="margin-top:20px;" id="save-summary" class="btn btn-primary btn-sm pull-right" value="Upload" />
</div>
</div>
</form>
我在这个文件中的 ajax 函数是:
$('#form_submit7').submit(function(){
var formVars = $(this).serialize();
**alert(formVars);**
$.ajax({
type: 'POST',
url: '{/literal}{$site_url}expo/booth_company_logo/{$id}{literal}',
data: formVars,
cache: false,
success: function(data)
{
//alert(data);
$('#company-pro').html(data);
$('#radios').css("display","none");
}
});
return false;
});
但是在警报部分的这个ajax函数中没有任何数据来......
【问题讨论】:
-
您没有显示整个代码 - 您的代码中有 {/literal} 这意味着您之前也使用过它,也不清楚您的问题是什么。请添加更多失败
-
实际上这个是 smarty 模板的 .tpl 文件,所以在开始 jquery/javascript 代码之前,我们必须传递文字,所以在这段代码之前我已经传递了 {literal} 标签,我在这里只给出了函数。 ...
标签: codeigniter smarty