PhoneGap的文件传输成功回调错误

发布于 2025-01-08 09:12:43 字数 1517 浏览 1 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

萌︼了一个春 2025-01-15 09:12:43

看起来“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.

时光沙漏 2025-01-15 09:12:43

我的范围也有同样的问题。尝试像这样调用该函数:

this.onSuccessCreateActualite.bind(this)

在您的 upload() 方法中。

I had the same problem with my scope. Try calling the function like this:

this.onSuccessCreateActualite.bind(this)

in your upload() method.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文