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

jquery get data value

http://jsfiddle.net/Kzd57/6/

"[[{"MYID":22636,"MyComment":"testing text box","BID":11069},{"MYID":22636,"MyComment":"next comment","BID":11070}]]"

Open in new window


Not knowing why I cannot retrieve these values. not sure what is different than when I done before.
0
Seven price
Asked:
Seven price
  • 4
  • 2
1 Solution
 
leakim971PluritechnicianCommented:
you don't run the function
you don't have a valid JSON objet to use $.each
you have an if(obj.BlotterId) and nowhere BlotterId

Test page : http://jsfiddle.net/Qq656/

function fnSuccess(response) {
	var toAppend = "";
	alert("test");

	var obj = jQuery.parseJSON(response);
	$.each(obj, function(i, item) {
		//if(typeof obj.BlotterID != 'undefined') {
			//$('.stack').show();
      		toAppend += '<div style=""><label>Comments #11 : </label><textarea id=' + item.BID + '  name='+  obj.BID + '"  cols="40" rows="6">' + item.myComment + '</textarea></div>'; 
		//}
 	});
	$('.stack').append(toAppend);
}

fnSuccess('[{"MYID":22636,"myComment":"testing text box","BID":11069},{"MYID":22636,"myComment":"next comment","BID":11070}]');

Open in new window

0
 
Seven priceFull StackAuthor Commented:
I see but this is the way the data is returned and I get undefined error.

http://jsfiddle.net/Qq656/12/
0
 
Seven priceFull StackAuthor Commented:
var data = $.parseJSON(response.d.toString()); 
$.each(data, function(i, item) {
alert(item);
$('.stack').show();

Open in new window


I do not freakin understand, this all should work but I just cannot get the data to show within the div but I can see it in the popup and in the DOM.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Seven priceFull StackAuthor Commented:
Response
{"d":"[[{\"myID\":22636,\"Comment\":\"testing text box\",\"BID\":11069},{\"ID\":22636,\"Comment\":\"next comment\",\"BID\":11070}]]"}

Json
d	"[[{"myID":22636,"Comment":"testing text box","BID":11069},{"ID":22636,"Comment":"next comment","BID":11070}]]"

Open in new window


what is going on.
0
 
leakim971PluritechnicianCommented:
http://jsfiddle.net/Qq656/16/

function fnSuccess(response) {
	var toAppend = "";
	alert("test");

	var obj = jQuery.parseJSON(response.d)[0];
	$.each(obj, function(i, item) {
		//if(typeof obj.BlotterID != 'undefined') {
			//$('.stack').show();
      		toAppend += '<div style=""><label>Comments #11 : </label><textarea id=' + item.BID + '  name='+  obj.BID + '"  cols="40" rows="6">' + item.Comment + '</textarea></div>'; 
		//}
 	});
	$('.stack').append(toAppend);
}

fnSuccess({"d":"[[{\"myID\":22636,\"Comment\":\"testing text box\",\"BID\":11069},{\"ID\":22636,\"Comment\":\"next comment\",\"BID\":11070}]]"}
)

Open in new window

0
 
Seven priceFull StackAuthor Commented:
I just learned it was not the front end, it is the way I selected in link. wow something new. Thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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