I'm working on a piece of JavaScript. I'm completely new to JS, But I have a group of checkboxes part of the domainchkb class and with the name, all with different values. I am trying to group those into an array to format into JSON. When executing the code the debugger stops at return this.parent().text();. What am I doing wrong here? Any help would be appreciated.
function format4Cart(){
var domains;
var values = $('input[name=domainchkb]:checked').map(function(){
return this.parent().text();
}).get();
domains = "{\"type\" : \"single\", \"data\" : [";
$.each(values, function(domainIndex,selected_domain){
domains += "{\"id\" : \""+selected_domain+"\", \"domain\" : \""+whois_response.data.domain+"\"},";
});
$(domains).text().replace(/(\s+)?.$/,"");
domains += "]}";
domains=encodeURIComponent(domains);
ajaxAdd2Cart(domains);
}