昨天更新Aptana的时候发现Aptana网站上多了一个JAXER,不知为何物。google了一把也只找到一个介绍的翻译,再回网站上看了一下,原来是22日刚发布的。不过看过简单介绍后,觉得最吸引人的地方就是这几张图
![](https://i-blog.csdnimg.cn/blog_migrate/c2a0bba590833b85c621ce24b9f5501b.png)
直接运行htm页面,服务器端运行的javascript,服务器端和浏览器端都能运行的方法,还有可以从浏览器端调用的服务器端的方法,有点意思,感觉有点像asp.net。马上研究了一下它的API文档( http://aptana.com/reference/jaxer/api/Jaxer.index-frame.html),基本的东西都全了,数据库支持mySql和SQLite。
SQLite使用太方便了,找了一个SQLiteSpy带的world.db3数据库,使用最新的Aptana(已经包括了JAXER插件和服务器),结合jquery做了一个简单的例子。
全部代码如下:
1
<!
DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"
>
2
<
html
>
3
<
head
>
4
<
meta
http-equiv
="Content-Type"
content
="text/html; charset=utf8"
/>
5
<
title
>
Untitled Document
</
title
>
6![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
<
script
language
=javascript
src
=jquery.js
>
7
</
script
>
8![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
<
script
runat
=server-proxy
>
9![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
function getTable(rows)
{
10
var a = new Array();
11
a[0] = rows;
12![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
var conn = new Jaxer.DB.SQLite.Connection(
{
13
PATH: "E:\\test\\sqlite\\world.db3"
14
});
15
var rs = conn.execute("Select * from [City] where id <= ?", a);
16
return (rs.toHTML());
17
}
18
</
script
>
19![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
<
script
language
=JavaScript
>
20![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
$(function()
{
21![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
$("#button1").click(function()
{
22
$("#div1").append(getTable(1000));
23
});
24![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
$("#button2").click(function()
{
25
getTableAsync(setdata, 1000)
26
});
27![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
$("#button3").click(function()
{
28
$("#div1").html("");
29
});
30
});
31![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
function setdata(table)
{
32
$("#div1").html(table);
33
}
34
35
</
script
>
36
</
head
>
37
<
body
>
38
<
input
type
=button
id
=button1
value
=同步方法
><
input
type
=button
id
=button2
value
=异步方法
><
input
type
=button
id
=button3
value
=清除
>
39
<
div
id
=div1
>
40
</
div
>
41
</
body
>
42
</
html
>
43
![](/Images/OutliningIndicators/None.gif)
2
![](/Images/OutliningIndicators/None.gif)
3
![](/Images/OutliningIndicators/None.gif)
4
![](/Images/OutliningIndicators/None.gif)
5
![](/Images/OutliningIndicators/None.gif)
6
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
7
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
8
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
9
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
10
![](/Images/OutliningIndicators/InBlock.gif)
11
![](/Images/OutliningIndicators/InBlock.gif)
12
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
13
![](/Images/OutliningIndicators/InBlock.gif)
14
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
15
![](/Images/OutliningIndicators/InBlock.gif)
16
![](/Images/OutliningIndicators/InBlock.gif)
17
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
18
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
19
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
20
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
21
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
22
![](/Images/OutliningIndicators/InBlock.gif)
23
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
24
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
25
![](/Images/OutliningIndicators/InBlock.gif)
26
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
27
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
28
![](/Images/OutliningIndicators/InBlock.gif)
29
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
30
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
31
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
32
![](/Images/OutliningIndicators/InBlock.gif)
33
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
34
![](/Images/OutliningIndicators/InBlock.gif)
35
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
36
![](/Images/OutliningIndicators/None.gif)
37
![](/Images/OutliningIndicators/None.gif)
38
![](/Images/OutliningIndicators/None.gif)
39
![](/Images/OutliningIndicators/None.gif)
40
![](/Images/OutliningIndicators/None.gif)
41
![](/Images/OutliningIndicators/None.gif)
42
![](/Images/OutliningIndicators/None.gif)
43
![](/Images/OutliningIndicators/None.gif)
运行截图:
![](https://i-blog.csdnimg.cn/blog_migrate/533ed518c0df95459c6bbd143cbd35b6.jpeg)
详细的就不说了,关键是 <script runat=server-proxy>...</script>这部分,在客户端生成了这么两个方法:
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](/Images/OutliningIndicators/None.gif)
这样在浏览器端的js就可以直接使用了。
虽然还有很多问题,最讨厌的就是生成的页面上有全部的clientFramework的源代码,虽然是压缩的,但看着还是很麻烦,估计以后的版本这个是首先要修改的。
上面的例子可以到这里 http://download.csdn.net/user/luq885/直接下载,就是页面和一个jquery.js。
再说一下用JAXER服务器运行的方法,到 http://aptana.com/jaxer/download这里下载一个JAXER的服务器端,附带着Apache服务器,直接解压后运行 StartServers.bat就可以启动,把上面那个页面和jquery.js放到public文件夹下,访问 http://127.0.0.1:8081/test2.html就可以看到效果。