Display appropriate message after function in popup window returns something and close popup Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Storing Objects in HTML5 localStorageSet cookie and get cookie with JavaScriptWhen and where does JavaScript run, how about PHP? Can I combine the two?Jquery cookie monitorPopup Window will not CloseDisplay Message on same popup windowwindow.opener is useless after a redirect in the popup window (JavaScript)Reference - What does this error mean in PHP?Executing function when pop-up window with redirects inside is closedJavascript: closing a popup windowClosing popup windows on clickPerform action after a popup window is closedClose popup window if user log out in angularRedirecting to new page after closing popup window

Dating a Former Employee

What would be the ideal power source for a cybernetic eye?

What causes the direction of lightning flashes?

Wu formula for manifolds with boundary

Closed form of recurrent arithmetic series summation

Do square wave exist?

For a new assistant professor in CS, how to build/manage a publication pipeline

When the Haste spell ends on a creature, do attackers have advantage against that creature?

8 Prisoners wearing hats

Why are there no cargo aircraft with "flying wing" design?

Why aren't air breathing engines used as small first stages

Does classifying an integer as a discrete log require it be part of a multiplicative group?

If a VARCHAR(MAX) column is included in an index, is the entire value always stored in the index page(s)?

Is it fair for a professor to grade us on the possession of past papers?

An adverb for when you're not exaggerating

Denied boarding although I have proper visa and documentation. To whom should I make a complaint?

How to Make a Beautiful Stacked 3D Plot

First console to have temporary backward compatibility

Using audio cues to encourage good posture

Is there a kind of relay only consumes power when switching?

How to tell that you are a giant?

Most bit efficient text communication method?

What is the meaning of the new sigil in Game of Thrones Season 8 intro?

Extracting terms with certain heads in a function



Display appropriate message after function in popup window returns something and close popup



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!Storing Objects in HTML5 localStorageSet cookie and get cookie with JavaScriptWhen and where does JavaScript run, how about PHP? Can I combine the two?Jquery cookie monitorPopup Window will not CloseDisplay Message on same popup windowwindow.opener is useless after a redirect in the popup window (JavaScript)Reference - What does this error mean in PHP?Executing function when pop-up window with redirects inside is closedJavascript: closing a popup windowClosing popup windows on clickPerform action after a popup window is closedClose popup window if user log out in angularRedirecting to new page after closing popup window



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I'm making a system that uses authorization through an external API (VK). When the user clicks on "authorize via VK", they get a popup window where they can choose whether to grant permissions or cancel. Whatever they choose, the API just redirects them to my php script in the same popup window, and when that script is done, they are ending up with an empty popup window still open.



I need to do 2 things:



1) Close the popup window after the script is done.



2) Depending on what the function in the script returns, display the appropriate message for the user, not in that popup window, but in the initial window that initiated the popup (somewhere between the lines of the already existing text), after the popup has already closed.



Now, I don't know how to do this. There must me some javascript (preferrably jquery) that inserts a message to the initial window depending on the response obtained from the function that was called in a popup window that has already closed.



Here are some excerpts from the system:



http://example.com/vkcode?error=access_denied&error_reason=user_denied&error_description=User+denied+your+request&state=secret_state_code - this is the page the user gets redirected to (inside the popup) if they choose "cancel". And they keep staying on the blank page with that string in their address bar.



Here is some PHP code that handles the response from VK API:



public function vkAuthHandler() 
if (isset($_GET['error']))
if ($_GET['error_reason'] == 'user_denied'
return 'user_denied';

else return 'error';

else
// ... haven't written other logic yet, it's irrelevant anyway

return new Response();



Now, if I receive 'user_denied' response, I need to display a message telling the user that they refused the permissions. But not in that popup window where that function was called (it should already be closed by the time), but on the initial page, without reloading it.










share|improve this question



















  • 1





    Imagine if you will, that you are someone else. And they are reading your question without the knowledge of your application that you already have. Would it make sense to you? Would you have enough knowledge of the actual logic already developed to know what needed to be modified, with what you have provided?

    – Taplar
    Mar 8 at 18:58












  • But I asked it as a general question. 1) How to close the popup window after a php script is done. 2) How to pass the response of that php script to a javascript that's on the initial page and not on the popup page. Totally makes sense to me.

    – COOLak
    Mar 8 at 19:02











  • StackOverflow is not looking for general question, especially when it is about specific logic that you have already developed, that we have no idea about. General questions are appropriate for well known things, like existing public libraries or plugins perhaps. Not custom code that developers at large are unaware of the details about. You have to give us the details. Else we are limited to guessing.

    – Taplar
    Mar 8 at 19:04











  • I added some excerpts to my question, but I have no idea how they help.

    – COOLak
    Mar 8 at 19:08


















0















I'm making a system that uses authorization through an external API (VK). When the user clicks on "authorize via VK", they get a popup window where they can choose whether to grant permissions or cancel. Whatever they choose, the API just redirects them to my php script in the same popup window, and when that script is done, they are ending up with an empty popup window still open.



I need to do 2 things:



1) Close the popup window after the script is done.



2) Depending on what the function in the script returns, display the appropriate message for the user, not in that popup window, but in the initial window that initiated the popup (somewhere between the lines of the already existing text), after the popup has already closed.



Now, I don't know how to do this. There must me some javascript (preferrably jquery) that inserts a message to the initial window depending on the response obtained from the function that was called in a popup window that has already closed.



Here are some excerpts from the system:



http://example.com/vkcode?error=access_denied&error_reason=user_denied&error_description=User+denied+your+request&state=secret_state_code - this is the page the user gets redirected to (inside the popup) if they choose "cancel". And they keep staying on the blank page with that string in their address bar.



Here is some PHP code that handles the response from VK API:



public function vkAuthHandler() 
if (isset($_GET['error']))
if ($_GET['error_reason'] == 'user_denied'
return 'user_denied';

else return 'error';

else
// ... haven't written other logic yet, it's irrelevant anyway

return new Response();



Now, if I receive 'user_denied' response, I need to display a message telling the user that they refused the permissions. But not in that popup window where that function was called (it should already be closed by the time), but on the initial page, without reloading it.










share|improve this question



















  • 1





    Imagine if you will, that you are someone else. And they are reading your question without the knowledge of your application that you already have. Would it make sense to you? Would you have enough knowledge of the actual logic already developed to know what needed to be modified, with what you have provided?

    – Taplar
    Mar 8 at 18:58












  • But I asked it as a general question. 1) How to close the popup window after a php script is done. 2) How to pass the response of that php script to a javascript that's on the initial page and not on the popup page. Totally makes sense to me.

    – COOLak
    Mar 8 at 19:02











  • StackOverflow is not looking for general question, especially when it is about specific logic that you have already developed, that we have no idea about. General questions are appropriate for well known things, like existing public libraries or plugins perhaps. Not custom code that developers at large are unaware of the details about. You have to give us the details. Else we are limited to guessing.

    – Taplar
    Mar 8 at 19:04











  • I added some excerpts to my question, but I have no idea how they help.

    – COOLak
    Mar 8 at 19:08














0












0








0








I'm making a system that uses authorization through an external API (VK). When the user clicks on "authorize via VK", they get a popup window where they can choose whether to grant permissions or cancel. Whatever they choose, the API just redirects them to my php script in the same popup window, and when that script is done, they are ending up with an empty popup window still open.



I need to do 2 things:



1) Close the popup window after the script is done.



2) Depending on what the function in the script returns, display the appropriate message for the user, not in that popup window, but in the initial window that initiated the popup (somewhere between the lines of the already existing text), after the popup has already closed.



Now, I don't know how to do this. There must me some javascript (preferrably jquery) that inserts a message to the initial window depending on the response obtained from the function that was called in a popup window that has already closed.



Here are some excerpts from the system:



http://example.com/vkcode?error=access_denied&error_reason=user_denied&error_description=User+denied+your+request&state=secret_state_code - this is the page the user gets redirected to (inside the popup) if they choose "cancel". And they keep staying on the blank page with that string in their address bar.



Here is some PHP code that handles the response from VK API:



public function vkAuthHandler() 
if (isset($_GET['error']))
if ($_GET['error_reason'] == 'user_denied'
return 'user_denied';

else return 'error';

else
// ... haven't written other logic yet, it's irrelevant anyway

return new Response();



Now, if I receive 'user_denied' response, I need to display a message telling the user that they refused the permissions. But not in that popup window where that function was called (it should already be closed by the time), but on the initial page, without reloading it.










share|improve this question
















I'm making a system that uses authorization through an external API (VK). When the user clicks on "authorize via VK", they get a popup window where they can choose whether to grant permissions or cancel. Whatever they choose, the API just redirects them to my php script in the same popup window, and when that script is done, they are ending up with an empty popup window still open.



I need to do 2 things:



1) Close the popup window after the script is done.



2) Depending on what the function in the script returns, display the appropriate message for the user, not in that popup window, but in the initial window that initiated the popup (somewhere between the lines of the already existing text), after the popup has already closed.



Now, I don't know how to do this. There must me some javascript (preferrably jquery) that inserts a message to the initial window depending on the response obtained from the function that was called in a popup window that has already closed.



Here are some excerpts from the system:



http://example.com/vkcode?error=access_denied&error_reason=user_denied&error_description=User+denied+your+request&state=secret_state_code - this is the page the user gets redirected to (inside the popup) if they choose "cancel". And they keep staying on the blank page with that string in their address bar.



Here is some PHP code that handles the response from VK API:



public function vkAuthHandler() 
if (isset($_GET['error']))
if ($_GET['error_reason'] == 'user_denied'
return 'user_denied';

else return 'error';

else
// ... haven't written other logic yet, it's irrelevant anyway

return new Response();



Now, if I receive 'user_denied' response, I need to display a message telling the user that they refused the permissions. But not in that popup window where that function was called (it should already be closed by the time), but on the initial page, without reloading it.







javascript php jquery






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 at 19:08







COOLak

















asked Mar 8 at 18:56









COOLakCOOLak

120111




120111







  • 1





    Imagine if you will, that you are someone else. And they are reading your question without the knowledge of your application that you already have. Would it make sense to you? Would you have enough knowledge of the actual logic already developed to know what needed to be modified, with what you have provided?

    – Taplar
    Mar 8 at 18:58












  • But I asked it as a general question. 1) How to close the popup window after a php script is done. 2) How to pass the response of that php script to a javascript that's on the initial page and not on the popup page. Totally makes sense to me.

    – COOLak
    Mar 8 at 19:02











  • StackOverflow is not looking for general question, especially when it is about specific logic that you have already developed, that we have no idea about. General questions are appropriate for well known things, like existing public libraries or plugins perhaps. Not custom code that developers at large are unaware of the details about. You have to give us the details. Else we are limited to guessing.

    – Taplar
    Mar 8 at 19:04











  • I added some excerpts to my question, but I have no idea how they help.

    – COOLak
    Mar 8 at 19:08













  • 1





    Imagine if you will, that you are someone else. And they are reading your question without the knowledge of your application that you already have. Would it make sense to you? Would you have enough knowledge of the actual logic already developed to know what needed to be modified, with what you have provided?

    – Taplar
    Mar 8 at 18:58












  • But I asked it as a general question. 1) How to close the popup window after a php script is done. 2) How to pass the response of that php script to a javascript that's on the initial page and not on the popup page. Totally makes sense to me.

    – COOLak
    Mar 8 at 19:02











  • StackOverflow is not looking for general question, especially when it is about specific logic that you have already developed, that we have no idea about. General questions are appropriate for well known things, like existing public libraries or plugins perhaps. Not custom code that developers at large are unaware of the details about. You have to give us the details. Else we are limited to guessing.

    – Taplar
    Mar 8 at 19:04











  • I added some excerpts to my question, but I have no idea how they help.

    – COOLak
    Mar 8 at 19:08








1




1





Imagine if you will, that you are someone else. And they are reading your question without the knowledge of your application that you already have. Would it make sense to you? Would you have enough knowledge of the actual logic already developed to know what needed to be modified, with what you have provided?

– Taplar
Mar 8 at 18:58






Imagine if you will, that you are someone else. And they are reading your question without the knowledge of your application that you already have. Would it make sense to you? Would you have enough knowledge of the actual logic already developed to know what needed to be modified, with what you have provided?

– Taplar
Mar 8 at 18:58














But I asked it as a general question. 1) How to close the popup window after a php script is done. 2) How to pass the response of that php script to a javascript that's on the initial page and not on the popup page. Totally makes sense to me.

– COOLak
Mar 8 at 19:02





But I asked it as a general question. 1) How to close the popup window after a php script is done. 2) How to pass the response of that php script to a javascript that's on the initial page and not on the popup page. Totally makes sense to me.

– COOLak
Mar 8 at 19:02













StackOverflow is not looking for general question, especially when it is about specific logic that you have already developed, that we have no idea about. General questions are appropriate for well known things, like existing public libraries or plugins perhaps. Not custom code that developers at large are unaware of the details about. You have to give us the details. Else we are limited to guessing.

– Taplar
Mar 8 at 19:04





StackOverflow is not looking for general question, especially when it is about specific logic that you have already developed, that we have no idea about. General questions are appropriate for well known things, like existing public libraries or plugins perhaps. Not custom code that developers at large are unaware of the details about. You have to give us the details. Else we are limited to guessing.

– Taplar
Mar 8 at 19:04













I added some excerpts to my question, but I have no idea how they help.

– COOLak
Mar 8 at 19:08






I added some excerpts to my question, but I have no idea how they help.

– COOLak
Mar 8 at 19:08













1 Answer
1






active

oldest

votes


















0














I solved it in a sophisticated way. Not going to accept this answer because maybe someone offers a simplier solution.



In PHP:



public function vkAuthHandler() 
if (isset($_GET['error']))
if ($_GET['error_reason'] == 'user_denied'
header('Set-cookie: vkresp=user_denied');

else header('Set-cookie: vkresp=error');

else
// ...

echo "<script>window.close();</script>"; //closing the window here
return new Response();



In JavaScript (used jQuery and JS-Cookie), based on this solution:



var cookieRegistry = [];

function listenCookieChange(cookieName, callback)
setInterval(function() , 100);


listenCookieChange('vkresp', function()
if (Cookies.get('vkresp') == 'user_denied')
console.log('VK response is user_denied');
$("#VKauth").append('<div style="color: red;">You denied authorization! Comments are blocked!</div>');

else if (Cookies.get('vkresp') == 'error')
console.log('VK response is user_denied');
$("#VKauth").append('<div style="color: red;">Unknown authorization error. Try again.</div>');

Cookies.remove('vkresp');
);


$("#VKauth") is basically selecting an HTML element with the id VKauth on my page.






share|improve this answer

























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55069358%2fdisplay-appropriate-message-after-function-in-popup-window-returns-something-and%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I solved it in a sophisticated way. Not going to accept this answer because maybe someone offers a simplier solution.



    In PHP:



    public function vkAuthHandler() 
    if (isset($_GET['error']))
    if ($_GET['error_reason'] == 'user_denied'
    header('Set-cookie: vkresp=user_denied');

    else header('Set-cookie: vkresp=error');

    else
    // ...

    echo "<script>window.close();</script>"; //closing the window here
    return new Response();



    In JavaScript (used jQuery and JS-Cookie), based on this solution:



    var cookieRegistry = [];

    function listenCookieChange(cookieName, callback)
    setInterval(function() , 100);


    listenCookieChange('vkresp', function()
    if (Cookies.get('vkresp') == 'user_denied')
    console.log('VK response is user_denied');
    $("#VKauth").append('<div style="color: red;">You denied authorization! Comments are blocked!</div>');

    else if (Cookies.get('vkresp') == 'error')
    console.log('VK response is user_denied');
    $("#VKauth").append('<div style="color: red;">Unknown authorization error. Try again.</div>');

    Cookies.remove('vkresp');
    );


    $("#VKauth") is basically selecting an HTML element with the id VKauth on my page.






    share|improve this answer





























      0














      I solved it in a sophisticated way. Not going to accept this answer because maybe someone offers a simplier solution.



      In PHP:



      public function vkAuthHandler() 
      if (isset($_GET['error']))
      if ($_GET['error_reason'] == 'user_denied'
      header('Set-cookie: vkresp=user_denied');

      else header('Set-cookie: vkresp=error');

      else
      // ...

      echo "<script>window.close();</script>"; //closing the window here
      return new Response();



      In JavaScript (used jQuery and JS-Cookie), based on this solution:



      var cookieRegistry = [];

      function listenCookieChange(cookieName, callback)
      setInterval(function() , 100);


      listenCookieChange('vkresp', function()
      if (Cookies.get('vkresp') == 'user_denied')
      console.log('VK response is user_denied');
      $("#VKauth").append('<div style="color: red;">You denied authorization! Comments are blocked!</div>');

      else if (Cookies.get('vkresp') == 'error')
      console.log('VK response is user_denied');
      $("#VKauth").append('<div style="color: red;">Unknown authorization error. Try again.</div>');

      Cookies.remove('vkresp');
      );


      $("#VKauth") is basically selecting an HTML element with the id VKauth on my page.






      share|improve this answer



























        0












        0








        0







        I solved it in a sophisticated way. Not going to accept this answer because maybe someone offers a simplier solution.



        In PHP:



        public function vkAuthHandler() 
        if (isset($_GET['error']))
        if ($_GET['error_reason'] == 'user_denied'
        header('Set-cookie: vkresp=user_denied');

        else header('Set-cookie: vkresp=error');

        else
        // ...

        echo "<script>window.close();</script>"; //closing the window here
        return new Response();



        In JavaScript (used jQuery and JS-Cookie), based on this solution:



        var cookieRegistry = [];

        function listenCookieChange(cookieName, callback)
        setInterval(function() , 100);


        listenCookieChange('vkresp', function()
        if (Cookies.get('vkresp') == 'user_denied')
        console.log('VK response is user_denied');
        $("#VKauth").append('<div style="color: red;">You denied authorization! Comments are blocked!</div>');

        else if (Cookies.get('vkresp') == 'error')
        console.log('VK response is user_denied');
        $("#VKauth").append('<div style="color: red;">Unknown authorization error. Try again.</div>');

        Cookies.remove('vkresp');
        );


        $("#VKauth") is basically selecting an HTML element with the id VKauth on my page.






        share|improve this answer















        I solved it in a sophisticated way. Not going to accept this answer because maybe someone offers a simplier solution.



        In PHP:



        public function vkAuthHandler() 
        if (isset($_GET['error']))
        if ($_GET['error_reason'] == 'user_denied'
        header('Set-cookie: vkresp=user_denied');

        else header('Set-cookie: vkresp=error');

        else
        // ...

        echo "<script>window.close();</script>"; //closing the window here
        return new Response();



        In JavaScript (used jQuery and JS-Cookie), based on this solution:



        var cookieRegistry = [];

        function listenCookieChange(cookieName, callback)
        setInterval(function() , 100);


        listenCookieChange('vkresp', function()
        if (Cookies.get('vkresp') == 'user_denied')
        console.log('VK response is user_denied');
        $("#VKauth").append('<div style="color: red;">You denied authorization! Comments are blocked!</div>');

        else if (Cookies.get('vkresp') == 'error')
        console.log('VK response is user_denied');
        $("#VKauth").append('<div style="color: red;">Unknown authorization error. Try again.</div>');

        Cookies.remove('vkresp');
        );


        $("#VKauth") is basically selecting an HTML element with the id VKauth on my page.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 9 at 1:18

























        answered Mar 9 at 1:08









        COOLakCOOLak

        120111




        120111





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55069358%2fdisplay-appropriate-message-after-function-in-popup-window-returns-something-and%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            1928 у кіно

            Захаров Федір Захарович

            Ель Греко