আমার কাছে jQuery কোডের এই টুকরা রয়েছে যা সূক্ষ্ম ক্রস উত্সকে কাজ করে:
jQuery.ajax({
url: "http://example.appspot.com/rest/app",
type: "POST",
data: JSON.stringify({"foo":"bar"}),
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function (response) {
console.log("success");
},
error: function (response) {
console.log("failed");
}
});
এখন আমি এটিকে কোনও সফলতা ছাড়াই Angular.js কোডে রূপান্তর করতে চেষ্টা করছি:
$http({
url: "http://example.appspot.com/rest/app",
dataType: "json",
method: "POST",
data: JSON.stringify({"foo":"bar"}),
headers: {
"Content-Type": "application/json; charset=utf-8"
}
}).success(function(response){
$scope.response = response;
}).error(function(error){
$scope.error = error;
});
কোন সাহায্য প্রশংসা।