到 jquery 发布,jquery,post"/>

首页 > 解决方案 > 添加到 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 会看到图像的内容添加到脚本中?

标签: jquerypost

解决方案


推荐阅读