如何从AJAX响应中获取responseText
?以下是我的代码:
<audio controls>
<source ng-src="{{abc}}" type="audio/wav">
Your browser does not support the audio element.
</audio>
$scope.postTitle = function(a1) {
$scope.tce = a1;
console.log($scope.tce);
$.ajax({
type: 'POST',
url: 'http://language.cs.usm.my/synthesis/read.php',
data: {
'submit': 'submit',
'malayText': $scope.tce
}, // you can use as much as data you want to send,
dataType: 'JSON', // so you can use the json_encode php function
complete: function(response) {
console.log("Posted");
console.log(response.responseText);
$scope.text = (response.responseText);
$scope.url = $scope.text.substring(514, 568);
$scope.abc = $sce.trustAsResourceUrl($scope.url);
console.log($scope.url);
}
});
}
答案 0 :(得分:-1)
您不应该直接使用jQuery AJAX的响应/回调来调整范围。使用$http
获取响应以触发摘要周期。