-1
私は2つの約束とjavascript関数があります。完璧に動作ネストされた約束構造
uploadDocument = function (formData, order) {
$.ajax({
type: "POST",
url: "/API/Documents/addDocument",
data: formData,
contentType: false,
processData: false
}).then(function (documentID) {
order.referenceID = documentID;
return $.ajax({
type: "POST",
url: "/API/Documents/addOrder",
data: ko.toJSON(transaction),
contentType: "application/json"
});
}).then(function (result) {
return 'success';
});
}
を、APIは、成功を呼び出します。
関数の呼び出しは、次のとおりです。この時点で
uploadDocument(formData, order).then(function (data) {
console.log('success');
})
私はエラーを取得しています:私はworng
Uncaught TypeError: Cannot read property 'then' of undefined
何をしているのですか?
[例外TypeError:未定義の 'を' プロパティを読み取ることができません]の可能な重複(https://stackoverflow.com/questions/24788171/typeerror-cannot-read-property-then-of-undefined) – alexmac
デバッグあなたのコード。ブレークポイントを設定し、変数を調べます。 'console.log'ステートメントを挿入します。 –
これは本質的にはタイプミスですが、これは標準的なデバッグ手法を使い、エラーメッセージについて考えている他のバグのように見えます。その意味で、いいえ、それはdownvotingの基準である "有用な"質問ではありません。 –