从API到Cordova的返回值(通过文件传输)

Hi I'm trying to return a value from a API call via the file transfer plugin for cordova. I've shown below my php code for the API which is working fine and the Cordova code. Essentially what I want to do is turn the return statement in the API into a JS variable in Cordova. This is the Php code, the move_uploaded_file part works fine:

    protected function uploadPicturesAction()
    {
    move_uploaded_file($tmp_name, "/home/sean/images/{$name}.jpg");
    return $name;
    }

This is the cordova part, so here I am trying to get the variable $name to become a JS variable.

    fileTransfer.upload(image, encodeURI("sean.co.uk/api.php?action=uploadPictures"), imagePage2(), fail, options);

Any help would be much appreciated.

  1. Create a php file (f.i. loadpics.php) that contains function uploadPicturesAction either true including a library file or just hard coded.
  2. To that file add as last line:    echo uploadPicturesAction();
  3. In your javascript use ajax to call loadpics.php and assign the return value to your javascrpt variable.