Uncaught TypeError: Невозможно прочитать свойство 'substr' из неопределенного в onVehiclePhotoURISuccess - PullRequest
0 голосов
/ 13 марта 2019

Я не понимаю, почему я получаю эту ошибку

Uncaught TypeError: Невозможно прочитать свойство 'substr' из неопределенного в onFehiclePhotoURISuccess

на

options.fileName = imageURI.substr(imageURI.lastIndexOf('/') + 1);

любая информация будет очень полезна

ниже функции

Я получаю сообщение об ошибке в строке, указанной ниже.

   function onVehiclePhotoURISuccess(imageURI,position, type) {

    //Transfer the file to the server
    var win = function (r) {
        clearCache();
        retries = 0;
        $.mobile.loading( 'hide');
        appAlert('Image transferred successfully.');

        if (device.platform == 'android' || device.platform == 'Android' || device.platform == 'amazon-fireos' ) {
            moveVehiclePic(imageURI,type);
        } else {
            //iOS
            moveVehiclePiciOS(imageURI,type)
        }

    }

    var fail = function (error) {
        if (retries == 0) {
            retries ++
            setTimeout(function() {
                onVehiclePhotoURISuccess(imageURI,type)
            }, 1000)
        } else {
            retries = 0;
            clearCache();
            appAlert('Error uploading file. Code:'+ error.code+" Source:"+ error.source+" Target:"+ error.target);
        }
    }


    var now=new Date();
    var nowtime=now.timeNow();
    nowtime=nowtime.replace(/:/g,"");
    var filename = "VEH-"+type+localStorage.getItem("curIncidentId")+nowtime+".jpg";
    curVehFileName=filename;

    if (typeof position === "undefined" || position=="") {
        var imageLat="";
        var imageLng="";
    } else {
        var imageLat=position.coords.latitude;
        var imageLng=position.coords.longitude;
    }

    var options = new FileUploadOptions();
    options.fileKey = "file";
//=======`error line`=========
    options.fileName = imageURI.substr(imageURI.lastIndexOf('/') + 1);
//================
    options.mimeType = "image/jpeg";
    options.params = { 'un': un ,
                     'secret': secret,
                     'imageType':type,
                     'fn': filename,
                     'xRef': localStorage.getItem("curIncidentId"),
                     'lat':imageLat,
                     'lng':imageLng };


    $.mobile.loading( 'show', {
            text: 'Uploading image...',
            textVisible: true,
            theme: 'a',
            html: ""
        });

    var ft = new FileTransfer();    
    ft.upload(imageURI, encodeURI(wsImageUploadURL), win, fail, options);

}

мне удалось найти JSON загрузку в imageURI и теперь я получаю эту ошибку

Uncaught SyntaxError: Неожиданный токен i в JSON в позиции 1 в JSON.parse ()

navigator.camera.getPicture( function(imageInfo){ \\================ строка ошибки ======================== var oImage=JSON.parse(imageInfo) \\===================================================== var oMetaData=JSON.parse(oImage.json_metadata) callBack(oImage.filename,position,p1,p2,p3); }

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...