0
角度jについて学び始めています。私はポスト関数であるjavascript関数を持っています。今は角度jsに変換したいのですが。javascriptのポスト関数を角度jsに変換
<script>
function submitFunction() {
var ip_range = "";
var user_name = "wind";
$.post("software.aspx", {"action": "getchartdata","username": user_name},
function(data, status) {
if (status === "success") {
if (data) {
console.log(JSON.stringify(data));
dataParse(data);
} else {
alert("ALERT!");
}
alert(start_date)
}
alert(start_date)
});
}
</script>
私はこの古いジャバスクリプトからの戻り結果を得ることができ、それは私にJSONの結果を返します:
は、ここに私の古いjavascriptのコードです。以下は動作できなかった私の新しい角度js関数です。バックエンドコードを変更する必要があるかどうかはわかりません。
<script>
var app = angular.module('myApp', []);
app.controller('FormCtrl', function ($scope, $http) {
console.log("Preparing..")
$scope.submitForm = function() {
console.log("posting data....");
var username = $scope.form;
$http({
method: 'POST',
url: 'Software.aspx',
data: {username: username},
}).then(function successCallback(response) {
// this callback will be called asynchronously
// when the response is available
console.log("Success")
console.log(response)
}, function errorCallback(response) {
// called asynchronously if an error occurs
// or server returns response with an error status.
console.log("fail")
});
};
});
</script>
私は角度のあるjsに変換することを私に教えてくれませんか?ありがとう。
あなたは 'url: 'Software.aspx'、' – Satpal
のアクションを指定していません。コンソールログを確認してください –
どうしたらうまくいかないのですか?結果にHTTPステータスがありますか? – Mistalis