JSON formatting error help

JSON formatting error help

brianfidlerbrianfidler Posts: 21Questions: 1Answers: 0
edited October 2010 in General
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?

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi brianfidler,

    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
  • brianfidlerbrianfidler Posts: 21Questions: 1Answers: 0
    Hi 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
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Ah okay - if you are seeing 500 internal server error then you are looking in the right place, but unfortunately going to have to dive in a little deeper to find out what is going on... A 500 error is very generic and just means that "something has gone wrong" - it could be almost anything... What you'll need to do is look at the server error log (assuming you have access to these?) it's usually in /var/log/apache/error_log or similar if you are using Apache and *nix, or through a control panel if using one.

    Regards,
    Allan
  • brianfidlerbrianfidler Posts: 21Questions: 1Answers: 0
    I'm going to email you the log errors because I don't want the URL to be public.

    brian
  • brianfidlerbrianfidler Posts: 21Questions: 1Answers: 0
    Ha! I figured it out once I could see what was happening in the error log :)

    best $50 I spent all day :) sometimes its the little shoves that get me back on track.

    thanks
    brian
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Good to hear you got it sorted - nice one :-)

    Regards,
    Allan
This discussion has been closed.