【问题标题】:PhoneGap processMessage failed: Error: SyntaxError: Unexpected end of inputPhoneGap processMessage 失败:错误:SyntaxError:输入意外结束
【发布时间】:2013-08-08 22:16:17
【问题描述】:

大家好,我试图找出以下错误的解决方案

(D/CordovaLog(1512): file:///android_asset/www/cordova.js: Line 981 : processMessage failed: Error: SyntaxError: Unexpected end of input)

在 Android 上,相同的代码在 Ios 设备上运行良好,我检查并放置了文件传输方法所需的所有权限,如文档中定义的那样。

我还安装了我认为可以解决问题但没有运气的最新版本。

我使用 phonegap 文档中定义的以下实现。 这是我的源代码。

navigator.camera.getPicture(uploadPhoto, function(message){
//alert('get picture failed');
},{
quality: 50, 
destinationType: navigator.camera.DestinationType.FILE_URI,
sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY
}); 

var options = new FileUploadOptions();
options.fileKey="image";
options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1);
options.mimeType="image/jpeg";

var params = new Object();
var authtoken = window.localStorage.getItem("authtoken");
var username = window.localStorage.getItem("email");
var userid = window.localStorage.getItem("userId");
var spotid = window.localStorage.getItem("spotId");
var  message = private_key + authtoken + username
var md5message = CryptoJS.MD5( message );
//console.log(private_key +":"+ authtoken +":"+ username+":"+userid);
var auth_code = md5message.toString();
//console.log( auth_code );
params.authcode = auth_code;
params.user_id = userid;
params.spot_id = spotid;
options.params = params;
options.chunkedMode = false;
var ft = new FileTransfer();
ft.upload(imageURI, "http://beta.cityisyours.com/api/spot_picture_add", win, fail, options);

当我尝试使用FileTransfer() 上传图片时; 任何建议

【问题讨论】:

  • 你有这方面的最新消息吗?

标签: cordova


【解决方案1】:

在 navigator.camera.getPicture 中你引用了一个名为 uploadPhoto 的函数,你定义了吗?

另一个问题可能是这一行缺少分号:

var message = private_key + authtoken + username

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-08-05
    • 1970-01-01
    • 2019-12-27
    • 2015-08-05
    • 1970-01-01
    • 1970-01-01
    • 2018-10-03
    • 2020-03-26
    相关资源
    最近更新 更多