jquery - 添加到 jquery 发布
问题描述
有类似的东西:
<form name="cform" id="cform" method="post" enctype="multipart/form-data" action="{$sitepath}/comment.php">
<input type="file" class="custom-file-upload" name="image" id="exampleFormControlFile1"/>
<i class="mdi mdi-camera-enhance"></i> {#add_picture#}
<input type="text" name="url_add" id="test_{$firstsub.revid}" class="form-control pull-right" placeholder="{#url_add#}" style="display:none;"/>
<textarea name="text1" rows="3" cols="50" class="form-control" id="thirdfield"></textarea><br /><br />
<input type="submit" class="btn btn-info" name="submit" value="{#reply#}" />
</form>
工作正常/图像由comment.php 正常上传。
下面是相同的表单,但使用的是 jquery post。工作正常,但 javascript dosen 看不到图像...
<form name="cform0" id="cform0" method="post" enctype="multipart/form-data">
<input type="file" class="custom-file-upload" name="image" id="exampleFormControlFile1"/>
<i class="mdi mdi-camera-enhance"></i> {#add_picture#}
<textarea name="text1" rows="3" cols="50" class="form-control"></textarea><br /><br />
<input type="submit" id="submit_comment" class="btn btn-primary" name="submit" value="{#comment#}">
</form>
<script>
$('#newswhite').on('click', '#submit_comment', function() {
var url = "{$sitepath}/comment.php";
$.ajax({
type: "POST",
url: url,
data: $("#cform0").serialize(),
success: function(data)
{
$('#newswhite').load(location.href + " .newswhite1212");
}
});
return false;
});
</script>
有什么方法可以将我的comment.php 会看到图像的内容添加到脚本中?
解决方案
推荐阅读
- reactjs - 在滚动时调用 API 的平面列表无法正常工作
- c++ - 如何在c ++编译程序中找到导致分段错误的行
- angular - PrimeNG 动态对话框实例/组件内容
- python - Pandas:将特定表中的列名映射到另一个表中的行
- ajax - WooCommerce Ajax 添加到购物车 facebook 像素事件不起作用
- arduino - Arduino 脚本抛出错误“X 未在此范围内声明”
- python - Python新手 - 启动Python时突然出现错误
- html - 无法设置输入的默认值(Angular)
- java - java正则表达式包含某些字符串
- powershell - TeamCity 远程 Powershell 访问突然被拒绝