Reputation: 83
I have a PHP file that uploads a video to microsoft azure service through an api , which returns an object (StdObject) file. I want to send that back through ajax back to javascript. The video is successfully getting uploaded to azure, so no problems on that side. But when I try to see what is inside the "asset" object in js, its just empty. php vardump of the asset file is showing the contents properly. What am i doing wrong here ?
Here is my JS code:
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 code:
<?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);
?>
Upvotes: 0
Views: 330
Reputation:
Implement the The JsonSerializable interface to the class from which the object returned by the function uploadFileAndCreateAsset()
is created.
Upvotes: 1