Skip to content

Commit b1c0057

Browse files
Added button disabling to error handler
1 parent bf67539 commit b1c0057

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

Misc/Dall-E/web-dalle/js/script.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,17 @@ reqButton.onclick = function() {
4343
.then(res => res.json())
4444
// .then(json => console.log(json))
4545
.then(addImages)
46-
.catch(error => reqStatus.innerHTML = error);
46+
.catch(error => {
47+
reqStatus.innerHTML = error;
48+
reqButton.disabled = false;
49+
});
4750

4851
}
4952

5053
function addImages(jsonData)
5154
{
5255
reqButton.disabled = false;
56+
5357
if (jsonData.error)
5458
{
5559
reqStatus.innerHTML = 'ERROR: ' + jsonData.error.message;

Misc/Dall-E/web-gpt/js/script.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ reqButton.onclick = function () {
5858
fetch(gptEndpoint, reqParams)
5959
.then(res => res.json())
6060
.then(json => addText(json, prompt))
61-
.catch(error => reqStatus.innerHTML = error)
61+
.catch(error => {
62+
reqStatus.innerHTML = error;
63+
reqButton.disabled = false;
64+
});
6265
}
6366

6467

0 commit comments

Comments
 (0)