javascript - Uncaught InvalidStateError in JSON.stringify -
i've read other thread , no good: put data json jquery
whenever try json.stringify object array error saying:
uncaught invalidstateerror: attempt made use object not, or no longer, usable.
here js:
var responseitems = []; var keynotecontainer = $('div.keynote-questions'); var eventquestioncontainer = $('div.event-questions'); var sessioncontainer = $('div.session-questions'); var eventid = $('#evaluation-event-id').val(); keynotecontainer.children().each(function (index, el) { var element = $(el); var id = "-1"; var parentid = element.find('input[type=hidden]').val(); var parenttype = "keynote"; var responsevalue = element.find('.response-item-slider').slider("option", "value"); var responsetext = ""; var response = { "id": id, "eventid": eventid, "parentid": parentid, "parenttype": parenttype, "responsevalue": responsevalue, "responsetext": responsetext }; responseitems.push(response); }); eventquestioncontainer.children().each(function (index, el) { var element = $(el); var id = "-1"; var parentid = element.find('input[type=hidden]').val(); var parenttype = "eventquestion"; var responsevalue = element.find('.response-item-slider').slider("option", "value"); var responsetext = element.find('textarea').val(); var response = { "id": id, "eventid": eventid, "parentid": parentid, "parenttype": parenttype, "responsevalue": responsevalue, "responsetext": responsetext }; responseitems.push(response); }); sessioncontainer.children().each(function (index, el) { var element = $(el); var id = "-1"; var parentid = element.find('input[type=hidden]').val(); var parenttype = "session"; var responsevalue = element.find('.response-item-slider').slider("option", "value"); var responsetext = ""; var response = { "id": id, "eventid": eventid, "parentid": parentid, "parenttype": parenttype, "responsevalue": responsevalue, "responsetext": responsetext }; responseitems.push(response); }); responseitems = json.stringify(responseitems);
i've tried log , breaks @ last line stringify it.
how can fix this? piece of advise or information highly appreciated.
i had same error. in case, had forgotten .val() when setting 1 of model properties. there wasn't error until tried json.stringify model
this.model.set( { customername: this.$("#customername").val(), jobtitle: this.$("#jobtitle"), //this line causing error testimonialtext: this.$("#testimonialtext").val() });
Comments
Post a Comment