# -*- coding: utf-8 -*-
import flask, json
import time
import pymongo
client=pymongo.MongoClient(host="localhost",port=27017)
sheetc=client.fox.fox_url
# data=sheetc.find({"id":{ "$exists" : True }}).sort('id',1)
# print(sheetc.find({"id":{ "$exists" : True }}).sort('id',1))
server = flask.Flask(__name__) # 创建一个服务,把当前这个python文件当做一个服务
@server.route('/VIID/System/Tim', methods=['get']) # @server.route()可以将普通函数转变为服务、接口的路径、请求方式,如果不写methods则默认get方法
def Timea():
#获取ajax请求的参数:ajax代码见下面
id = request.args["id"]
if id == "heo":
print("Aaa")
from bson import json_util
data=sheetc.find({"id":{ "$exists" : True }}).sort('id',-1)
'''查询字符串:无,消息体:无,返回结果:SystemTime'''
response_data =json_util.dumps(data)
print(response_data)
return json.dumps(response_data, ensure_ascii=False)
if __name__ == '__main__':
server.run(debug=True, port=5030, host='127.0.0.3') # 指定访问端口、host
ajax:
var data
function loadXMLDoc()
{$(function(){
$.ajax({
async: true,
type: "GET",
dataType: 'text',
jsonp: 'callback',
jsonpCallback: 'callbackfunction',
url: "v/VIID/System/Time",
data: {id:"heo"},
timeout: 3000,
contentType: "application/json;utf-8",
success: function(data) {
console.log("vv")
// console.log(data);
a=JSON.parse(data)
console.log(a)
}
});
})}
window.onscroll = function(){
imgone=$("#img>img").first()
img=$("#img")
// var $img =$(img),
viewH =imgone.height(),//图片高度
contentH =img.height(),//内容高度
scrollTop =$(document).scrollTop();//滚动高度
if(contentH - viewH - scrollTop <= 100) {
console.log("aa")
//到达底部100px时,加载新内容
// if(scrollTop/(contentH -viewH)>=0.95){ //到达底部100px时,加载新内容
// // 这里加载数据..
}
console.log(scrollTop)
}