localhost中的jquery $ .get没有收到响应

时间:2015-06-06 00:38:25

标签: jquery node.js express

我试图使用jquery发出GET请求来接收具有用户确定的命名空间的页面。我的索引页面(在jade中)有一个文本输入表单,该脚本使用:

org.skife.jdbi.v2.exceptions.UnableToExecuteStatementException: org.h2.jdbc.JdbcSQLException: Cannot parse "TIMESTAMP" constant "aced0005737200166f72672e6a6f64612e74696d652e4461746554696d65b83c78646a5bddf90200007872001f6f72672e6a6f64612e74696d652e626173652e426173654461746554696d65fffff9e14f5d2ea30200024a0007694d696c6c69734c000b694368726f6e6f6c6f677974001a4c6f72672f6a6f64612f74696d652f4368726f6e6f6c6f67793b78700000014b030b30c0737200276f72672e6a6f64612e74696d652e6368726f6e6f2e49534f4368726f6e6f6c6f67792453747562a9c811667137502703000078707372001f6f72672e6a6f64612e74696d652e4461746554696d655a6f6e652453747562a62f019a7c321ae3030000787077150013416d65726963612f4c6f735f416e67656c65737878"; SQL statement:

[SQL statement]

at org.h2.util.DateTimeUtils.parseDateValue(DateTimeUtils.java:275)
at org.h2.value.ValueTimestamp.parseTry(ValueTimestamp.java:140)
at org.h2.value.ValueTimestamp.parse(ValueTimestamp.java:120)
at org.h2.value.Value.convertTo(Value.java:862)
at org.h2.table.Column.convert(Column.java:148)
at org.h2.command.dml.Insert.insertRows(Insert.java:143)
at org.h2.command.dml.Insert.update(Insert.java:114)
at org.h2.command.CommandContainer.update(CommandContainer.java:78)
at org.h2.command.Command.executeUpdate(Command.java:254)
at org.h2.jdbc.JdbcPreparedStatement.execute(JdbcPreparedStatement.java:198)
at org.skife.jdbi.v2.SQLStatement.internalExecute(SQLStatement.java:1328)
at org.skife.jdbi.v2.Update.execute(Update.java:56)
at org.skife.jdbi.v2.sqlobject.UpdateHandler$2.value(UpdateHandler.java:62)
at org.skife.jdbi.v2.sqlobject.UpdateHandler.invoke(UpdateHandler.java:75)
at org.skife.jdbi.v2.sqlobject.SqlObject.invoke(SqlObject.java:175)
at org.skife.jdbi.v2.sqlobject.SqlObject$1.intercept(SqlObject.java:75)
at org.skife.jdbi.v2.sqlobject.CloseInternalDoNotUseThisClass$$EnhancerByCGLIB$$4df23516.insert(<generated>)

该应用程序使用路由器进行所有&#39; / chat&#39;请求,据我所知,请求url localhost:3000 / chat / namespace进入路由器,其中包含以下代码:

script(src="http://code.jquery.com/jquery-1.11.1.js")
script(type="text/javascript"). 
            $(document).ready(function(){
                $('form').submit(function(){
                    $.get('http://localhost:3000/chat/' + $('#n').val());
                });
            });

然后使用用户确定的命名空间呈现另一个jade文件。但是,在索引页面上提交表单只是刷新索引页面,地址栏显示router.use(function(req, res){ var namespace = req.originalUrl; res.render('../views/chat', {namespace: namespace, pageTitle: 'chatroom'}); }); 。我不确定我的语法是否错误,或者我尝试做的事情是否存在更深层次的问题。我尝试过$ .get()其他字符串,例如&#39; / chat&#39;。

1 个答案:

答案 0 :(得分:0)

尝试

$(document).ready(function(){
    $('form').submit(function(event){
        $.get('http://localhost:3000/chat/' + $('#n').val());
        event.preventDefault();  //<--- prevent form from submitting, which will refresh the page before the AJAX call completes
    });
});