我有一个PHP文件,它通过api向microsoft azure服务上传视频,api返回一个对象(StdObject)文件。我想通过ajax把它发回javascript。视频正在成功地上传到azure,所以在那一端没有问题。但是,当我尝试查看js中的"asset“对象中的内容时,结果却是空的。资源文件的php vardump正确地显示了内容。我在这里做错了什么?
下面是我的JS代码:
var asset;
$.ajax({
type: "POST",
url: "internal_api/uploadasset.php",
cache: false,
processData: false,
contentType: false,
data: form_data,
success: function(data){
rowid = data.rowid;
asset = data.videoasset;
console.log(asset);
alert("Video successfully uploaded");
},
error: function() {
alert("Error");
},
dataType: 'json',
});
PHP代码:
<?php
require_once '../vendor/autoload.php';
include './config.php';
include_once 'azureconfig.inc';
use WindowsAzure\Common\ServicesBuilder;
use WindowsAzure\Common\Internal\MediaServicesSettings;
use WindowsAzure\Common\Internal\Utilities;
use WindowsAzure\MediaServices\Models\Asset;
/*
all azure code comes here
*/
$videoAsset = uploadFileAndCreateAsset($restProxy,$video_file,$video_name);
$query = mysql_query("insert into tbl_videos (filename,userid,clipid,type).....")
$rowid = mysql_insert_id();
$return['rowid'] = $rowid;
$return['videoasset'] = $videoAsset;
echo json_encode($return);
?>
发布于 2017-07-18 09:57:30
将The JsonSerializable interface实现到创建函数uploadFileAndCreateAsset()
返回的对象所基于的类。
https://stackoverflow.com/questions/45162426
复制相似问题