微信js 上传多个照片IOS,只上传了最后一个

来源:互联网 发布:mysql开发者权威指南 编辑:程序博客网 时间:2024/04/29 14:54

一开始用的each循环,android可以,执行多次wx.uploadImage,但在IOS中却只执行最后一个上传方法

也许因为wx.uploadImage 有执行成功失败的回调函数

这里用递归解决`

function upload() {    wx.uploadImage({        localId : localIds[i],        success : function(res) {            serverIds.push(res.serverId);            i++;            if (i < length) {                upload();            } else {                alert("serverIds" + serverIds);                $.ajax({                    type : "post",                    url : "upload.do",                    data : {                        "serverIds" : serverIds,                        "name" : name,                        "tel" : tel,                        "email" : email                    },                    success : function() {                        alert("提交成功");                    },                    fail : function() {                        alert("服务器异常");                    }                });            }        },        fail : function() {            alert("upload fail please wait a moment and try again");        }    });}`
0 0
原创粉丝点击