我在index.php
:
$f3->map('/user', 'User');
User
类看起来像这样:
<?php
class User {
function __construct($f3) {
$this->users = new \DB\SQL\Mapper($f3->db, 'users');
}
function get($f3) {
return json_encode('Just some text');
}
function post($f3) {
// There is tested, working code in here but I've omitted it for simplicity's sake
}
function put($f3) {
}
function delete() {
}
}
我首先通过app.js加载我的Javascript:
$(document).ready(function(){
var currentPage = $(location).attr('pathname'),
requiredJS = document.createElement('script'),
requiredJS.type = 'text/javascript';
switch(currentPage) {
case '/mypage':
requiredJS.src = 'myscript.js';
$('body').append(requiredJS);
break;
// more cases...
}
});
然后我在mypage.js
中的简单AJAX调用如下所示:
$.get('/user', function (data) {
console.log(data);
});
当我转到/mypage
路线时,我的控制台中只有一个空字符串。为什么会这样?我搞砸了哪里?
答案 0 :(得分:1)
你应该回应结果:
SELECT CAST(CollectionDate as DATETIME) + CAST(CollectionTime as DATETIME)
FROM field