Skip to content

Commit e95ce1f

Browse files
committed
fixed static jsonp example and reordered solari.js
1 parent e558e61 commit e95ce1f

2 files changed

Lines changed: 16 additions & 22 deletions

File tree

‎example/postJsonp.py‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@
44
from __future__ import print_function
55

66
import json
7+
import cgi
8+
import sys
79

810
def cgi():
9-
data = [
10-
{'sDate':'today','sTime':'13:30','sDeparture':'foo@example.com','nStatus':1,'nTrack':17, 'fLight':true},
11-
{'sDate':'yesterday','sTime':'16:00','sDeparture':'bar@example.com','nStatus':2,'nTrack':19, 'fLight':false},
12-
{'sDate':'July 8th, 2013','sTime':'16:30','sDeparture':'baz@example.com','nStatus':2,'nTrack':23, 'fLight':false}
13-
]
11+
data = [ {'sDate':'today','sTime':'13:30','sDeparture':'foo@example.com','nStatus':1,'nTrack':17, 'fLight':True},
12+
{'sDate':'yesterday','sTime':'16:00','sDeparture':'bar@example.com','nStatus':2,'nTrack':19, 'fLight':False},
13+
{'sDate':'July 8th, 2013','sTime':'16:30','sDeparture':'baz@example.com','nStatus':2,'nTrack':23, 'fLight':False}]
14+
1415
print("Content-Type: application/json", end='\n\n')
15-
print("jsonpCallback(" + json.dumps(data, sys.stdout) + ")"
16+
print("jsonpCallback(" +json.dumps(data, sys.stdout) + ")")
1617

1718
if __name__ == '__main__':
1819
cgi()

‎js/solari.js‎

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -318,32 +318,25 @@ function GetFailBoard() {
318318
return board;
319319
}
320320

321+
function jsonpCallback(data){
322+
if (data !== null) {
323+
solariData = data.slice(0);
324+
failboard = false;
325+
}
326+
}
327+
321328
function updateSolariBoard() {
322329
$.ajax({
323330
url: URL + "?callback=?",
324331
cache: false,
325332
type: "POST",
326333
dataType: "jsonp",
327334
jsonpCallback: "jsonpCallback",
328-
success: function (data) {
329-
if (data !== null) {
330-
console.log(data);
331-
solariData = data.slice(0);
332-
failboard = false;
333-
}
334-
},
335335
error: function () {
336336
failboard = true;
337337
}
338-
});
339-
340-
function jsonpCallback(data){
341-
if (data !== null) {
342-
solariData = data.slice(0);
343-
failboard = false;
344-
}
345-
}
346-
338+
});
339+
347340
// update last refresh time text
348341
$('#last-updated span').fadeOut("slow", function() {
349342
var now = new Date();

0 commit comments

Comments
 (0)