• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
two views with javascript. One works, one doesn't. Why?

#1
I am using javascript to create 2 messages that I am sending from my CI program to my Chrome Extension. This is the first one that seems to run fine. I am calling it from a method in one of my controllers. The message snapshot_mode is correctly sent to the Chrome Extension.
Code:
<script language="javascript">

   $(document).ready( function() {
       var editorExtensionId = "lamacgnkfoiknjpleghfknfigbmhdaei";

       // Make a simple request:
       chrome.runtime.sendMessage(editorExtensionId, "snapshot_mode",
           function (response) {
               if (!response.success)
                   handleError(url);

           }
       )
   })

</script>


Later, when the user logs off the application I am calling this from a different function in the same controller:
Code:
<script language="javascript">



       var editorExtensionId = "lamacgnkfoiknjpleghfknfigbmhdaei";

       // Make a simple request:
       chrome.runtime.sendMessage(editorExtensionId, "snapshot_mode_unload",
           function (response) {
               if (!response.success)
                   handleError(url);

           }
       )


</script>
Almost exactly the same, right? The unload doesn't work. I haven't been able to debug the javascript code in phpStorm, but I know that the message is not arriving at the Extension. It is true in the code that shortly after calling the unload function above, I am clearing the session and then redirecting. Without debugging both the php and javascript at the same time, how can I solve this problem?
Reply

#2
Have you tried using your browsers development tools F12 ?

Bring up the developer tools in the console tab and watch what the javascript is doing etc;
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#3
Ill try that. It is funny that the one with the .ready works but the "naked" one doesn't.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.