Ajaxsubmit函数不会给我成功消息但是图像上传

时间:2014-12-24 17:30:40

标签: jquery ajax image-uploading

以下是从文件输入类型更改的脚本请看一下。请分享我如何显示回复。

$('#files').change(function(){        

    var url = $(this).val();
    var ext = url.substring(url.lastIndexOf('.') + 1).toLowerCase();
    var ajaximgupload="1";
    if (ext == "gif" || ext == "png" || ext == "jpeg" || ext == "jpg") 
    {           
         $("#myForm").ajaxSubmit({
             url: '<?php echo Router::url(array('controller'=>'floats','action'=>'index'))?>',
             data: ({attachement:url}),
             dataType: "text/html",
             cache: false,
             type: "post",
             success: function(response) {                  
                 alert(response);
                $("#target").attr("src","/uploads/attachement/"+response);
             },
             resetForm: true
         });

    } else {  alert("Invalid Image Format"); return false;}
});

0 个答案:

没有答案