Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mistake in readme/wiki need to replace info about editing $.post in js #8

Open
dexx0008 opened this issue Dec 13, 2013 · 2 comments
Open

Comments

@dexx0008
Copy link

Hi, I'd like to point out a mistake, hopefully get a question answered, and offer contribute a php file that will deliver json to be provided as an example. I have access to php more often than python.

The error in your configuration documentation:
Your read me and wiki still contain information about editing $.post

  1. Point the board to the script that will feed it jsonp
    $.post('../example/postJson.py') // replace this with your own script
    when the project has changed to require editing this in solari.js
    var URL = "../example/postJsonp.py"

I do have a question. I'm attempting to send json from php to the board and I am having zero luck. The board displays but get the the fail whale EVERY time.

my settings:
-index.html file in example/ based off readme,
-provider.php in example/ (this sends jsonp)
-var URL = "../example/provider.php" //this changed in solari.js (no other changes elsewhere, in this file or others)

My test of php is to call the provider.php from a browser (chrome) like so.
http://localhost/board/example/provider.php?callback=test

the response is:
test ([{"sDate":"today","sTime":"13:30","sDeparture":"[email protected]","nStatus":1,"nTrack":17,"fLight":true},{"sDate":"today","sTime":"13:30","sDeparture":"[email protected]","nStatus":1,"nTrack":17,"fLight":true},{"sDate":"today","sTime":"13:30","sDeparture":"[email protected]","nStatus":1,"nTrack":17,"fLight":true}])

The only difference is single vs. double quotes that php json_encode() function puts in. (i'm pulling in values from a multidimensional array. I used the project sample data to test.

Is there something else this that I am missing??? I just don't see what it would be unless I'm not submitting the json payload as mentioned in solari.js properly.

thank you,
Ryan

My php file is simply this. It requires php 5.2 and up

'today', 'sTime' => '13:30', 'sDeparture' => '[email protected]', 'nStatus' => 1, 'nTrack' => 17, 'fLight' => true)); array_push($data, array('sDate' => 'today', 'sTime' => '13:30', 'sDeparture' => '[email protected]', 'nStatus' => 1, 'nTrack' => 17, 'fLight' => true)); array_push($data, array('sDate' => 'today', 'sTime' => '13:30', 'sDeparture' => '[email protected]', 'nStatus' => 1, 'nTrack' => 17, 'fLight' => true)); $json = json_encode($data); header("Content-type: application/json"); //echo 'callbackname (' . $json . ')'; #test echo $_GET['callback'] . ' (' . $json . ')'; ?>
@dexx0008
Copy link
Author

update: There is definitely something wrong with the implementation of solari.js

Firebug shows this 404 error when attempting to grab the json. Notice the lack of ? after provider.php before callback=… is added.

The requested URL /final/example/provider.phpcallback=jQuery203041688141632170084_1386973248944 was not found on this server.

If I add a ? to URL variable in solari.js as shown below.
var URL = "../example/provider.php?"

I get a 200 ok response for the jsonp that is returned. jsonp looks good now but solari.js fails after this though as nothing else loads.

This probably explains why another poster complained that repo didn't work unless he assigned json to a variable within solari.js with the sample data provided at the top of that .js file.

Fixed it. 2 things in solari.js
1 add ? to $.getJSON
$.getJSON(URL + "?callback=?", function(data) {

2 var timeDelta = Date.parse(next_due_row.sDate + " " + time).getTime() - new Date().getTime();
should be:
var timeDelta = Date.parse(next_due_row.sDate + " " + time).getTime() - new Date().getTime();

note the comma, firebug reported error on Date.parse…

I also now see this project was forked and that same issue was found. Please update the code for others.

This now works for me in MAMP with php creating jsonp from a php array. Thanks for publishing this solariboard for us to use.

Ryan

@dexx0008
Copy link
Author

dexx0008 commented Jan 7, 2014

oops, didn't alter line for timeDelta
it should be this (with the comma)
var timeDelta = Date.parse(next_due_row.sDate + ", " + time).getTime() - new Date().getTime();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant