iframe 无刷新上传图片以及返回值

Iframe 无刷新上传图片以及获取返回值


后台PHP代码:

$imginfo = $upload->getUploadFileInfo ();
$wall_img = $imginfo [0] ['savepath'] . $imginfo [0] ['savename'];
$array=array(
      'wall_img'=>$wall_img,
 );
 echo '<script type="text/javascript"> window.parent.setVal("'.$wall_img.'");</script> ';


IFRAME


<iframe name="ajaxUpload" style="display:none" id="pic_url"></iframe>
 
                             
                            <form name="from1" id="from1" method="post" action="index.php?g=Wap&m=Store&a=put_wall_img"  enctype="multipart/form-data" target="ajaxUpload"> 
                            <input type="button" data-inline="true" value="  上传图片  "  οnclick='file_upload.click();'>
                            <input type="file"  value="  上传图片  "  name="file_upload" id="file_upload" style="display:none" data-role="none">
                            </form>


$("#file_upload").change(function(){
        $("#from1").submit();   
        setTimeout('goto_bottom()', 500) ;
    });
    function setVal(val){
         var $li = $(
                    '<div class="content_one"><img src="'+$('#img1').val()+'" class="content_one1"><div style="position:relative; overflow:hidden;"><img src="" id="pic_wall_list" style="max-width:50%; border:#CCC 1px solid; margin-left:3%"><input data-role="none" type="button" value="点击发送图片" class="content_send"></div> </div>'
                    ),
             $img = $li.find('#pic_wall_list');
            // $list为容器jQuery实例
            $('.msg').append($li);
            $img.attr( 'src', val );
            $li.find(".content_send").click(function(){
                var _this=this;
                $.ajax({
                    url:"index.php?g=Wap&m=Store&a=do_put_wall_img",
                    type:"post",
                    dataType:"json",
                    data:"pic_url="+val,
                    success:function(data){
                        if(data=="success"){
                            $(_this).val("发送成功");
                            $(_this).css('color','green');
                            $(_this).unbind("click"); 
                        }
                    }
                });
        });
    }


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值