• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 377
  • Last Modified:

jquery remove double brackets

http://jsfiddle.net/Qq656/29/

yes how do i remove double brackets if rendered. if there is one bracket check if two then remove.
0
Seven price
Asked:
Seven price
1 Solution
 
Robert SchuttSoftware EngineerCommented:
try this:
var obj = $.parseJSON(response.replace(/^\[(\[.*\])\]$/,"$1"));

Open in new window

http://jsfiddle.net/Qq656/36/
0
 
Randy PooleCommented:
function fnSuccess(response) {
	var toAppend = "";
    response=response.replace("[[","[");
    response=response.replace("]]","]");
	//alert("test");
var obj = $.parseJSON(response); 
//	var obj = jQuery.parseJSON(response);
	$.each(obj, function(i, item) {
        alert(JSON.stringify(obj));
      		toAppend += '<div style=""><label>Comments #11 : </label><textarea id=' + item.BID + '  name='+  item.BID + '"  cols="40" rows="6">' + item.myComment + '</textarea></div>'; 
		//}
 	});
	$('.stack').append(toAppend);
}

Open in new window

0
 
Seven priceFull StackAuthor Commented:
thanks Robert Schutt: much cleaner. and I love expressions.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now