title: jQuery check if form data are equal
body: <blockquote>
  <p><strong>Possible Duplicate:</strong><br />
  <a href="https://stackoverflow.com/questions/1773069/using-jquery-to-compare-two-arrays">Using jQuery to compare two arrays</a></p>
  </blockquote>
  
  <p>I have to send the form data via ajax to server on say every 30 second. Now I want it to be checked at client end and ajax been hit only in case there is any change in form. I am using:</p>
  <pre><code>var lastData = &quot;&quot;;
  function saveFormInDB(){
      var $form = $(&quot;#fb_divBl0ck1&quot;).closest('form');
      var isSame = false;
      data = $form.serializeArray();
      if(lastData == &quot;&quot;){
          lastData = data;
      }else{
          if(lastData == data){
              isSame = true;
          }
          lastData = data;
      }
      if(!isSame){
          jqxhr = $.post(&quot;/SPSKMEForm/FormSaveServlet&quot;, data)
          .success(function() {
              if(jqxhr.responseText != &quot;&quot;){
                  alert(jqxhr.responseText);
                  alert($(&quot;#fixedFooter&quot;));
                  alert($(&quot;#fixedFooter&quot;).html());
                  $(&quot;#fixedFooter&quot;).text(jqxhr.responseText).css(&quot;display&quot;, &quot;&quot;);
                  $(&quot;#fixedFooter&quot;).fadeOut(&quot;slow&quot;);
              }
          });
      }
  }
  </code></pre>
  <p>but <code>isSame</code> is coming to be false always.</p>