Click here to Skip to main content
15,436,567 members
Home / Discussions / JavaScript
   

JavaScript

 
GeneralRe: Is there a delicate way to pass calendar events variables in Javascript Pin
Member 1505943129-Jan-21 1:58
MemberMember 1505943129-Jan-21 1:58 
GeneralBuild an entire React application in one command Pin
DonJon28-Jan-21 19:22
MemberDonJon28-Jan-21 19:22 
GeneralRe: Build an entire React application in one command Pin
Richard Deeming28-Jan-21 22:14
mveRichard Deeming28-Jan-21 22:14 
QuestionBest way to trace JavaScript Conflict Pin
ReverseAds10-Jan-21 20:35
MemberReverseAds10-Jan-21 20:35 
QuestionRe: Best way to trace JavaScript Conflict Pin
Sandeep Mewara10-Jan-21 21:13
mveSandeep Mewara10-Jan-21 21:13 
AnswerRe: Best way to trace JavaScript Conflict Pin
20212a15-Jan-21 8:16
Member20212a15-Jan-21 8:16 
AnswerRe: Best way to trace JavaScript Conflict Pin
F-ES Sitecore28-Jan-21 21:24
professionalF-ES Sitecore28-Jan-21 21:24 
Questionhow to convert a function in to arrow function Pin
Member 139980429-Jan-21 0:56
MemberMember 139980429-Jan-21 0:56 
AnswerRe: how to convert a function in to arrow function Pin
Afzaal Ahmad Zeeshan9-Jan-21 4:35
mveAfzaal Ahmad Zeeshan9-Jan-21 4:35 
SuggestionRe: how to convert a function in to arrow function Pin
Richard Deeming11-Jan-21 22:41
mveRichard Deeming11-Jan-21 22:41 
QuestionQuiz Issue Pin
Shobhit Rathour30-Dec-20 3:35
MemberShobhit Rathour30-Dec-20 3:35 
AnswerRe: Quiz Issue Pin
Afzaal Ahmad Zeeshan9-Jan-21 5:02
mveAfzaal Ahmad Zeeshan9-Jan-21 5:02 
QuestionReplacing the eval() function with something faster, more safe Pin
jkirkerx21-Dec-20 7:52
professionaljkirkerx21-Dec-20 7:52 
AnswerRe: Replacing the eval() function with something faster, more safe Pin
Graham Breach21-Dec-20 8:27
MemberGraham Breach21-Dec-20 8:27 
GeneralRe: Replacing the eval() function with something faster, more safe Pin
jkirkerx21-Dec-20 9:21
professionaljkirkerx21-Dec-20 9:21 
Questionhigher order functions Pin
atomattacker-png21-Dec-20 1:49
Memberatomattacker-png21-Dec-20 1:49 
AnswerRe: higher order functions Pin
Richard MacCutchan21-Dec-20 2:06
mveRichard MacCutchan21-Dec-20 2:06 
GeneralRe: higher order functions Pin
atomattacker-png21-Dec-20 2:21
Memberatomattacker-png21-Dec-20 2:21 
GeneralRe: higher order functions Pin
Richard MacCutchan21-Dec-20 3:13
mveRichard MacCutchan21-Dec-20 3:13 
GeneralRe: higher order functions Pin
Richard MacCutchan21-Dec-20 4:02
mveRichard MacCutchan21-Dec-20 4:02 
GeneralRe: higher order functions Pin
atomattacker-png21-Dec-20 4:36
Memberatomattacker-png21-Dec-20 4:36 
GeneralRe: higher order functions Pin
Richard MacCutchan21-Dec-20 4:44
mveRichard MacCutchan21-Dec-20 4:44 
QuestionAttempting to pre-populate text field and mailto based on ID Pin
Member 1502531419-Dec-20 1:10
MemberMember 1502531419-Dec-20 1:10 
QuestionLooking to run a PHP page in the background using pure Javascript Pin
jkirkerx17-Dec-20 13:50
professionaljkirkerx17-Dec-20 13:50 
I've been searching around the web. Found indexedDB.open and tried it out. But I really need some sort of call back, or a promise when the PHP page has finished.

Below seems to work, but returns success right away and the spinner doesn't show.

Just looking for better ideas. Or maybe I can build on this. It's a start at least.
function saveWithProgress(stage) {

    console.log("Save with Progress - Calling msrp.phtml");
    const spinner = document.getElementById('spinnerOverlay');    

    if (stage == 'construction') {

        let note = prompt('Please brief summary of changes - construction', '');
        if (note != '' && note != null) {

            spinner.classList.remove('hide');<br />
            spinner.classList.add('show');

            const cUrl = 'msrp.phtml?save=1&new_note=' + note + '&cachebuster=' + (new Date()).valueOf();
            let openRequest = indexedDB.open(cUrl, 1);

            openRequest.onsuccess = (event) => {

                console.log('Save with Progress Construction - Success!');
                var db = event.target.result;
                console.log("Save with Progress Construction - ", db);

                spinner.classList.remove('show');<br />
                spinner.classList.add('hide');

            };

            openRequest.onerror = (error) => {

                console.log('Save with Progress Construction - ', error);

            };

        }
    } 
    else 
    {
        if (confirm('Are you sure that you want to save the changes? - everything but construction')) {

            spinner.classList.remove('hide');<br />
            spinner.classList.add('show');

            const saveUrl = 'msrp.phtml?save=1&cachebuster=' + (new Date()).valueOf();
            let openRequest = indexedDB.open(saveUrl, 1);

            openRequest.onsuccess = (event) => {

                console.log('Save with Progress - Success!');
                var db = event.target.result;
                console.log("Save with Progress - ", db);

                spinner.classList.remove('show');<br />
                spinner.classList.add('hide');

            };

            openRequest.onerror = (error) => {

                console.log('Save with Progress Construction - ', error);

            };           

        }
    }

    return false;

}
If it ain't broke don't fix it
Discover my world at jkirkerx.com

AnswerRe: Looking to run a PHP page in the background using pure Javascript Pin
DerekT-P17-Dec-20 22:54
professionalDerekT-P17-Dec-20 22:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.