上传按钮触发,Ajax跨越请求
$("#uploadBtn").change(function() { if (typeof (FileReader) != "undefined") { var formdata = new FormData(); var v_this = $(this); var fileObj = v_this.get(0).files; var img = $("#imgPath"); formdata.append("imgFile", fileObj[0]); $.ajax({ url: "https://api.longqiuhong.com/upload/images", type: "POST", dataType: "JSON", async: false, data: formdata, cache: false, contentType: false, processData: false, timeout: 5000, success: function(data) { if (data.success == true) { img.attr('src', data.url); img.css('display', 'block'); $("#uploadFile").val(data.url); } else { alert("上传错误!!"); } }, error: function(XMLHttpRequest, textStatus, errorThrown) { console.log(errorThrown) } }); } });
*
回帖描述:*
链接类型:*
下载链接:*
描述:*
回帖描述:*
链接类型:*
阅读权限:*
下载链接:



聚优部落技术论坛 © 版权所有 鲁ICP备15007479号-6
Copyright(C)web.com, All Rights Reserved.
