Welcome Guest, Not a member yet? Register   Sign In
How to pass in a struct to javascript
#1

(This post was last modified: 06-04-2019, 04:22 PM by richb201.)

I am trying to pass a few strings into a js function, which then passes it to my Extension. It is not working. How do I pass the data struct in?
Here is how I am calling it:
$data = array(
   'command' => 'snapshot_mode1',
   'message' => 'My Message'
);

$this->load->view("javascript_funcs_extensionloaded",$data);

I am not sure if "snapshot_mode1" it is getting into the js function. What is wrong with this? 

Code:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script language="javascript">


   $(document).ready( function(data) {
       var editorExtensionId = "lamacgnkfoiknjpleghfknfigbmhdaei";
       // unload when done
       $(window).on('beforeunload',(function(){
           chrome.runtime.sendMessage(editorExtensionId, "snapshot_mode_unload")
       }))


       chrome.runtime.sendMessage(editorExtensionId, data.command,
      // chrome.runtime.sendMessage(editorExtensionId, "snapshot_mode3",
           function (response) {
               if (!response.success)
                   handleError(url);

           }
       )

       })


</script>
proof that an old dog can learn new tricks
Reply


Messages In This Thread
How to pass in a struct to javascript - by richb201 - 06-04-2019, 04:19 PM



Theme © iAndrew 2016 - Forum software by © MyBB