JSON formatting error help
JSON formatting error help
brianfidler
Posts: 21Questions: 1Answers: 0
I am creating a table of records and using server processing to load each record into my Datatable. I need to make a call to the Zillow API for each record.
When I try to display the page I get this error:
DataTables warning: JSON data from server failed to load or be parsed. This is most likely to be caused by a JSON formatting error.
my function looks like this:
[code]<?php
require 'pillow/lib/pillow.php';
function getZillowValue ($address, $zip) {
$pf = new Pillow_Factory( 'my-zws-id' );
$property = $pf->findExactProperty($address, $zip, true);
$propertyAmount = $property->zestimate->amount;
return $propertyAmount;
}
?>
[/code]
...and I'm loading the column for each row using this in the server_processing.php script:
[code]$row[16] = '$'.number_format(getZillowValue($aRow[ 'PROPADDR' ], $aRow[ 'PROPZIP' ]));[/code]
When I run the function on its own it works fine. Any ideas what I am doing wrong?
When I try to display the page I get this error:
DataTables warning: JSON data from server failed to load or be parsed. This is most likely to be caused by a JSON formatting error.
my function looks like this:
[code]<?php
require 'pillow/lib/pillow.php';
function getZillowValue ($address, $zip) {
$pf = new Pillow_Factory( 'my-zws-id' );
$property = $pf->findExactProperty($address, $zip, true);
$propertyAmount = $property->zestimate->amount;
return $propertyAmount;
}
?>
[/code]
...and I'm loading the column for each row using this in the server_processing.php script:
[code]$row[16] = '$'.number_format(getZillowValue($aRow[ 'PROPADDR' ], $aRow[ 'PROPZIP' ]));[/code]
When I run the function on its own it works fine. Any ideas what I am doing wrong?
This discussion has been closed.
Replies
If you fire up Firefox and Firebug, what does the JSON return from the server look like? Given the error you are getting it's going to be malformed JSON, but how it's malformed will give a clue as to what the issue is.
Are you using the version of the server-side processing script which is using JSON encode - from your $row[16], I'd guess that's the case. If so, there it's likely you are getting either an exception, or SQL error or something like that. If you can post the JSON return here, we can take a look.
Regards,
Allan
I am using Firefox and Firebug but I can't see any JSON when I get the error. It is VERY possible I don't know what I'm doing though.
I'm currently looking in NET->XHR->Response tab which is empty. The error it is reporting is a 500 Internal Server Error.
thanks
brian
Regards,
Allan
brian
best $50 I spent all day :) sometimes its the little shoves that get me back on track.
thanks
brian
Regards,
Allan