我在jQuery的ajax函数中没有任何expirience.我想尝试简单的调用:
$.get ("ajaxsupport/login");
我有一个带url-pattern的servlet("ajaxsupport/login").
当我输入浏览器的地址字段" http:// localhost:9090/ajaxsupport/login "时,我看到了一些结果.但$ .get(..)甚至没有打电话.
问题是什么?
我使用jquery 1.3.1
$.get默认情况下是一个异步方法调用,这意味着调用者仍然处于控制之中.这就是为什么必须在请求执行时发生的事情.您可以通过定义回调来指定.
jQuery.get( url, [data], [callback], [type] )
在你的情况下(注意前面的'/',它可能没有必要,具体取决于脚本位置):
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
    $.get("/ajaxsupport/login", 
        function(data, textStatus){ 
            // just prompt the response and the status message
            alert(data + "\n" + textStatus); 
        } 
    );
});
</script>
| 归档时间: | 
 | 
| 查看次数: | 3433 次 | 
| 最近记录: |