Click here to Skip to main content
15,881,938 members
Home / Discussions / JavaScript
   

JavaScript

 
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
atomattacker-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
atomattacker-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
Member 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 
GeneralRe: Looking to run a PHP page in the background using pure Javascript Pin
jkirkerx18-Dec-20 6:10
professionaljkirkerx18-Dec-20 6:10 
GeneralRe: Looking to run a PHP page in the background using pure Javascript Pin
DerekT-P18-Dec-20 7:11
professionalDerekT-P18-Dec-20 7:11 
GeneralRe: Looking to run a PHP page in the background using pure Javascript Pin
jkirkerx18-Dec-20 7:53
professionaljkirkerx18-Dec-20 7:53 
GeneralRe: Looking to run a PHP page in the background using pure Javascript Pin
DerekT-P18-Dec-20 8:26
professionalDerekT-P18-Dec-20 8:26 
GeneralRe: Looking to run a PHP page in the background using pure Javascript Pin
jkirkerx18-Dec-20 8:47
professionaljkirkerx18-Dec-20 8:47 
AnswerRe: Looking to run a PHP page in the background using pure Javascript Pin
jkirkerx18-Dec-20 12:27
professionaljkirkerx18-Dec-20 12:27 
AnswerRe: Looking to run a PHP page in the background using pure Javascript Pin
jkirkerx18-Dec-20 13:31
professionaljkirkerx18-Dec-20 13:31 
AnswerGot it Pin
jkirkerx18-Dec-20 13:47
professionaljkirkerx18-Dec-20 13:47 
QuestionFinding the definition of a component from the place of its use Pin
simpledeveloper18-Dec-20 19:43
simpledeveloper18-Dec-20 19:43 
QuestionRe: Finding the definition of a component from the place of its use Pin
Richard MacCutchan17-Dec-20 23:39
mveRichard MacCutchan17-Dec-20 23:39 
AnswerRe: Finding the definition of a component from the place of its use Pin
simpledeveloper18-Dec-20 15:40
simpledeveloper18-Dec-20 15:40 
GeneralRe: Finding the definition of a component from the place of its use Pin
Richard MacCutchan18-Dec-20 22:40
mveRichard MacCutchan18-Dec-20 22:40 
Questiondatepicker on button click not working Pin
Dhyanga17-Dec-20 3:45
Dhyanga17-Dec-20 3:45 
QuestionTernary operator Pin
atomattacker-png12-Dec-20 5:06
atomattacker-png12-Dec-20 5:06 
AnswerRe: Ternary operator Pin
Sandeep Mewara12-Dec-20 5:42
mveSandeep Mewara12-Dec-20 5:42 
GeneralRe: Ternary operator Pin
atomattacker-png12-Dec-20 6:01
atomattacker-png12-Dec-20 6:01 

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.