以下のコードでは、特定の条件が満たされた場合に自分自身が間違ったページで見つかった可能性があります。そのような場合、私のコード内から$ http.get呼び出しを呼び出すと、スクリプトを続行する前にhtmlソースコードが取得されるのを待ちますか?スクリプトを続行する前に、新しいURLからhtmlを取得
function checkUrl(url, size, code) {
return $http.get(url).then(function(response) {
var html = response.data;
var listedPage = utility.countClass(html, 'product-tile');
if(listedPage > 1) {
url = getCorrectPage(html, code);
// this doesn't work, but I want to acquire the html of the newly acquired url
$http.get(url).then(function(response) {
html = response.data;
});
}
stockData.name = getProductName(html);
return stockData;
});
}
あなたは「これが動作しない」と言う、*どのような方法*で、それが「機能しない」のでしょうか?どのように失敗するのですか? 'url'はあなたが期待するものではありませんか?それはあなたが期待するものではありませんか?他に何か? – David