javascript - Error Converting circular structure to JSON -


what need

  • i need implement bookmark functionality toggling classes.

js , html code

var favoritedata = {};  $(document).ready(function() {    if (localstorage.getitem("favoritedata") !== null) {      $.each(favoritedata = json.parse(localstorage.getitem("favoritedata")), function(a) {        $("#" + a).addclass("fa fa-heart");        $("#" + a).removeclass("favourate_dextop");        $("#" + a).removeclass("fa-heart-o")      })    }      $(document).delegate(".favourate_dextop ", "click", function(a) {      alert(a);      favorite(this);      $(this).toggleclass("fa-heart-o").toggleclass("fa-heart ")    })  });    function favorite(a) {    alert(a);    if (favoritedata[a.id] !== undefined) {      delete favoritedata[a.id]    } else {      favoritedata[a.id] = $(a).data()    }    $(a).removeclass("faved");    localstorage.setitem("favoritedata", json.stringify(favoritedata));  };
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <ul class="icons_right pull-right">    <li>      <a href="javascript:void(0)" onclick="datalayer.push({'event':'addtofav'})" class=" fa-heart-o  favourate_dextop" data-toggle="tooltip" title="" id="fav3850" data-sess_id="3850" data-name="ramadan , eid exhibition" data-city="sharjah" data-country="united arab emirates"      data-event_url="ramadan-fair" data-original-title="follow &amp; bookmark"></a>    </li>  </ul>

problem

  • when click on heart icon throws error uncaught typeerror: converting circular structure json

  • i have cross checked script i"m unable find error.

console.log(favoritedata)

   object {fav74692: object}     fav74692: object     bs.tooltip: n     city: "graz"     country: "austria"     event_url: "festival-senses-graz"     name: "festival of senses graz"     sess_id: 74692     toggle: "tooltip"     __proto__: object     __proto__: object 


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -