Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to store and reproduce jQuery events
    primarykey
    data
    text
    <p>I am trying to store jQuery events in DB.</p> <pre><code>//Calling this Function On Click function trackevent(event){ window.events.push(event) } $.each(window.events, function(i, item){ console.log(i +" - "+ $.parseJSON(item)); }); </code></pre> <p>Events got stored to array. That's cool, but if I am trying to loop through <code>window.events</code> I can't get the jQuery event JSON back. I can't figure out my mistake. Any suggestions will be helpful.</p> <p><img src="https://i.stack.imgur.com/2nwJZ.png" alt="enter image description here"></p> <p>I am getting this error , if I changed parseJSON to JSON.stringify</p> <pre><code>$.each(window.events, function(i, item){ console.log(i +" - "+ JSON.stringify(item)); }); </code></pre> <p><img src="https://i.stack.imgur.com/3LWQN.png" alt="enter image description here"></p> <p><img src="https://i.stack.imgur.com/WpbkZ.png" alt="enter image description here"></p> <pre><code>$(document).ready(function(){ window.events = [] // Function to enable the hidden checkbox button $(".answers_checkbox").click(function(){ current_click = $(this).attr("data-attr"); // If the Hidden checkbox is Checked , it means its already selected (blue) if($("."+this.id).attr('checked') == 'checked') { $(this).css('background-image', ''); } else { // Changing the Background Image to current_click option $(this).css('background-image',"url('/assets/choice_buttons/choice"+current_click+"_Sq_Blue.png')"); } $("."+this.id).attr('checked',!$("."+this.id).attr('checked')); trackevent(event); }); function trackevent(event){ window.events.push(event) } }); // Function to Save Events $(window).bind('beforeunload', function(){ $.each(window.events, function(i, item){ console.log(i +" - "+ item); }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload