PhoneGap的文件传输成功回调错误
我正在使用 PhonGap 的 FileTransfert 方法,如下所示
var options = new FileUploadOptions();
options.fileKey="file";
options.mimeType="image/jpeg";
//options.chunkedMode = true;
var params = new Object();
params.title = title;
params.content = content;
params.groupId = groupId;
options.params = params;
var ft = new FileTransfer();
app.loadmask.show();
ft.upload(app.imageURI, app.stores.actionAjaxURL + "&cmd=addActualite", this.onSuccessCreateActualite, this.onFailureCreateActualite, options, true);
这将转到成功回调函数,即:
onSuccessCreateActualite: function(response, options) {
/* REINIT FORM VALUES */
app.imageURI = null;
console.log("This log appears");
this.titleField.reset();
console.log("This log does not appear");
this.groupSelect.reset();
this.contentField.reset();
this.addBtn.resumeEvents();
this.picturePnl.update("No Picture");
app.stores.actualites.load();
app.loadmask.hide();
app.views.viewport.actualites.setActiveItem(
app.views.viewport.actualites.actualitesList, {type:'slide', direction:'right'}
);
app.views.viewport.actualites.actualitesList.actuGrid.scroller.scrollTo({ x: 0, y: 0 });
},
我收到此错误:
成功回调中的错误:com.phonegap.filetransfer1 = TypeError:“未定义”不是对象
有人知道为什么吗?
谢谢
I'm using PhonGap's FileTransfert method like so
var options = new FileUploadOptions();
options.fileKey="file";
options.mimeType="image/jpeg";
//options.chunkedMode = true;
var params = new Object();
params.title = title;
params.content = content;
params.groupId = groupId;
options.params = params;
var ft = new FileTransfer();
app.loadmask.show();
ft.upload(app.imageURI, app.stores.actionAjaxURL + "&cmd=addActualite", this.onSuccessCreateActualite, this.onFailureCreateActualite, options, true);
This goes to the success callback function which is :
onSuccessCreateActualite: function(response, options) {
/* REINIT FORM VALUES */
app.imageURI = null;
console.log("This log appears");
this.titleField.reset();
console.log("This log does not appear");
this.groupSelect.reset();
this.contentField.reset();
this.addBtn.resumeEvents();
this.picturePnl.update("No Picture");
app.stores.actualites.load();
app.loadmask.hide();
app.views.viewport.actualites.setActiveItem(
app.views.viewport.actualites.actualitesList, {type:'slide', direction:'right'}
);
app.views.viewport.actualites.actualitesList.actuGrid.scroller.scrollTo({ x: 0, y: 0 });
},
And I'm getting this error :
Error in success callback: com.phonegap.filetransfer1 = TypeError: 'undefined' is not an object
Does anyone knows why ?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来“this.titleField”超出了 onSuccessCreateActualite 函数的范围。很可能“this”指的是与您想象的不同的对象。我会检查“this”的属性,看看它实际指的是什么。
It looks like "this.titleField" is out of scope in your onSuccessCreateActualite function. Most probably "this" is referring to a different object then you think it is. I'd inspect what the properties of "this" are to see what it actually refers to.
我的范围也有同样的问题。尝试像这样调用该函数:
在您的
upload()
方法中。I had the same problem with my scope. Try calling the function like this:
in your
upload()
method.