JSON array

I'm trying to get put some data into a div which is retrieved from a JSON request via ajax and jQuery:-
	$(document).ready(function () {
			type: 'GET',
			url: 'getTransactions.php?SessionID=53&AccountID=45565',
			dataType: 'json',
			success: function(retHtml, textStatus) {
			    var obj = jQuery.parseJSON(retHtml);
                $.each(obj, function(AccountID, transactionID, Date, transaction, Status, Amount, CountOfMemo) {
                    $('#divTransactions').append(AccountID + '<br/>');
                    $('#divTransactions').append(transactionID + '<br/>');
                    $('#divTransactions').append(Date + '<br/>');
                    $('#divTransactions').append(transaction + '<br/>');
                    $('#divTransactions').append(Status + '<br/>');
                    $('#divTransactions').append(Amount + '<br/>');
                    $('#divTransactions').append(CountOfMemo + '<br/><hr/>');
			error: function (xhr, textStatus, errorThrown) {
				alert(xhr + "\n" + textStatus + "\n" + errorThrown);

Open in new window

When I look at retHtml it seems to have pulled the JSON array back, however when the debugger tries to run 'var obj = jQuery.parseJSON(retHtml);' I get
Error: Unable to get property 'length' of undefined or null reference

The page which returns the JSON request (getTransactions.php) gives:-
{"AccountID":"66dcf4ef-4c8b-11e2-aa23-180373676ac7","transactionID":"39528e34-4c8b-11e2-aa23-180373676ac7","Date":"2012-12-24 00:00:00","transaction":"BILL PAYMENT","Status":"Cleared","Amount":"-350.07","CountOfMemo":"0"},
{"AccountID":"66dcf4ef-4c8b-11e2-aa23-180373676ac7","transactionID":"39528e3a-4c8b-11e2-aa23-180373676ac7","Date":"2012-12-22 00:00:00","transaction":"CARD PAYMENT","Status":"Cleared","Amount":"-6.33","CountOfMemo":"0"},
{"AccountID":"66dcf4ef-4c8b-11e2-aa23-180373676ac7","transactionID":"39528e35-4c8b-11e2-aa23-180373676ac7","Date":"2012-12-22 00:00:00","transaction":"CARD PAYMENT","Status":"Cleared","Amount":"-50.97","CountOfMemo":"0"}

Everything looks fine, I just cant get retHtml to get into an array correctly.

Any ideas what Im doing wrong?
Who is Participating?
leakim971Connect With a Mentor PluritechnicianCommented:
replace :
$.each(retHtml, function(AccountID, transactionID, Date, transaction, Status, Amount, CountOfMemo) {
                    $('#divTransactions').append(AccountID + '<br/>' + transactionID + '<br/>' + Date + '<br/>' + transaction + '<br/>' + Status + '<br/>' + Amount + '<br/>' + CountOfMemo + '<br/><hr/>');

Open in new window

by :
$.each(retHtml, function(i, v) {
                    $('#divTransactions').append(v.AccountID + '<br/>' + v.transactionID + '<br/>' + v.Date + '<br/>' + v.transaction + '<br/>' + Status + '<br/>' + v.Amount + '<br/>' + v.CountOfMemo + '<br/><hr/>');

Open in new window

could you provide a link to check ?
tonelm54Author Commented:
Ive put the code up onto a test site:-

Test Link
tonelm54Author Commented:

Thank you
tonelm54Author Commented:

Thank you
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.