No data yet received

No data yet received

grygry Posts: 2Questions: 0Answers: 0
edited August 2012 in Editor
I have installed and configured Editor to update a field in a MySQL table.
I am working on example 1, (the index file in examples directory) on my localhost.
The Data from database loads into the table no problem, but when I choose a field and update it, the status box on the right never updates.
It just says "// No data yet received"

I understand, in principal, that this means the server is not responding but I cannot understand why.
The program is reading from the database.. why not updating?

Any help would be greatly appreciated at this time.

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    I suspect that there has been an error in the server's processing of the data, and it isn't returning from that, or the process has been cancelled before any data can be returned. I'd suggest having a look at the error_log for your server to see if it provides any indication of what is going wrong - hopefully there will be a few error messages.

    Allan
  • grygry Posts: 2Questions: 0Answers: 0
    I believe that Editor calls php/browsers.php on submit.
    I have changed my "Browsers.php" file. here is the the function that I believe receives the $_POST

    [code]
    // Build our Editor instance and process the data coming from _POST
    Editor::inst( $db, 'apply_now_log' )
    ->fields(
    Field::inst( 'first_name' )->validator( 'Validate::required' )
    )
    ->process( $_POST )
    ->json();
    [/code]

    My table has many fields, does it matter that I have only mentioned this 1 field?
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    No - you can list and many or as few of the fields as you want.

    The files looks fine to me - at long are you include the DataTables library and `use` the required namespaces, like in my example files.

    Did you look at the server error log? Was there anything in there? Also, what version of PHP are you using? It must be 5.3 or newer for the DataTables libraries.

    Allan
  • lonnienlonnien Posts: 28Questions: 0Answers: 0
    edited September 2012
    My suggestion is to go simple until it actually works. Remove the validation use only one field, then when it does what you want to one field you can add as many as you want. Once you have all the fields working then get fancy and add validation. It makes troubleshooting easier if you have fewer things to go wrong and you might have a validation issue that stops the update.
  • lonnienlonnien Posts: 28Questions: 0Answers: 0
    Well, taking my own advice, I have one field being selected from a table. The data is pulled from the table (sqlite) and the json function gives this:
    (string) {"id":-1,"error":"","fieldErrors":[],"data":[],"aaData":[{"DT_RowId":"row_1","tag":"dictionary"},{"DT_RowId":"row_2","tag":"store"},{"DT_RowId":"row_3","tag":"license"},{"DT_RowId":"row_55","tag":"test"},{"DT_RowId":"row_756","tag":"576567567ghjnfgh"},{"DT_RowId":"row_757","tag":"data_test"},{"DT_RowId":"row_758","tag":"fghfgh"},{"DT_RowId":"row_759","tag":"test_db"}]}

    The table never shows anything and spits out a json formatting error. If I click the New button I can add another table entry (verified with another sqlite management tool), but nothing ever shows up in the table for display.

    So close, yet so far. Any ideas what I could be doing wrong? Nothing in the Apache logs either, so the code is pretty clean.

    from the php file.
    // Build our Editor instance and process the data coming from _POST
    Editor::inst( $db, 'dict_dbs' )
    ->fields(
    Field::inst( 'tag' )
    )
    ->process( $_POST )
    ->json();

    from the .js file
    $(document).ready(function() {
    var editor = new $.fn.dataTable.Editor( {
    "ajaxUrl": "/tabs/php/table.dict_dbs.php",
    "domTable": "#dict_dbs",
    "fields": [
    {
    "label": "Name",
    "name": "tag",
    "type": "text"
    }
    ]
    } );

    $('#dict_dbs').dataTable( {
    "sDom": "Tfrtip",
    "sAjaxSource": "/tabs/php/table.dict_dbs.php",
    "aoColumns": [
    {
    "mData": "tag"
    }
    ],
    "oTableTools": {
    "sRowSelect": "multi",
    "aButtons": [
    { "sExtends": "editor_create", "editor": editor },
    { "sExtends": "editor_edit", "editor": editor },
    { "sExtends": "editor_remove", "editor": editor }
    ]
    }
    } );
    } );
  • lonnienlonnien Posts: 28Questions: 0Answers: 0
    edited September 2012
    Further to the Inserting working. This is the json encode result:

    (string) {"id":"row_762","error":"","fieldErrors":[],"data":[],"row":{"DT_RowId":"row_762","tag":"real_data"}}

    It seems to have an error, but it actually does store the record and then on the Edit form says to contact the Administrator.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Is the `(string)` at the front of your return actually in the return from the server - because that will invalidate the JSON. Other than that it looks like it should work. If you could be me a link that would be very useful.

    Allan
  • lonnienlonnien Posts: 28Questions: 0Answers: 0
    Sorry about that. The (string) comes from copying the value from the php debugger. In order to see the value I store the json encode to a scratch variable and set a breakpoint so I could examine it. It gives the same browser result using your direct echo.

    if ( $print ) {
    $enc = json_encode( $this->_out );
    echo $enc;
    return $this;
    }

    Further to the json for the issue of not loading the initial table, it says {"id":-1. Since I have not had a working module I do not know if this is a problem or not. I am going to give this a try with pgsql or maybe even break down and install mysql. Once I can play with a working unit then I can fool with sqlite. It is awesome to see this almost working and little or no coding has been done. I'm sure it is something simple. Just have to find it. It would sure be nice to have a debugger in the browser for the javascript. Being able to single step and watch variables is so invaluable. Right now the javascript is a big black hole and I need a flashlight to see what is in the hole.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Okay - so the JSON is values from what is return by json_encode() which is expected! However, it is possible that is not the only thing that your script is echoing out. I'd suggest using Firebug or Inspector for Webkit to see what is actually being returned by the server.

    Allan
  • lonnienlonnien Posts: 28Questions: 0Answers: 0
    I'll give that a try. Something more to learn. So it goes. Can you give me some clues what to look for? As I said I have no idea what the output should look like. What else could be outputted? It seems so simple, to echo the json encoded data. Where could other stuff come from?
  • lonnienlonnien Posts: 28Questions: 0Answers: 0
    Problem SOLVED. I had added an echo in the Bootstrap (after the $db assign) to give me a place to breakpoint and I echoed it for something to see. Don't do that. That is a lesson I learned the hard way.

    $db = new Database( $sql_details );

    //echo ('after db assign for debugger');
    with the comment in place this works perfectly.

    This Editor is really cool. As part of my troubleshooting I changed to a Postgres database and it took all of 2 minutes. Now I can go wild.

    Thanks for an excellent piece of code. I have never worked with Namespaces but it sure looks good and for sure, you are a way better programmer than I. Very clever.
This discussion has been closed.