我想通过JQuery发出AJAX请求 以下是我的代码。Jquery无法向服务器发出Ajax请求
但是当我通过Mozilla Firebug进行调试时,我观察到,没有请求打到服务器。
请问有人能告诉我我做错了什么。
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JQuery Example</title>
</head>
<body>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$.ajax({
url: 'ajax/balances',
processData: false,
timeout: 10000,
type: "POST",
contentType: "application/xml",
dataType: "json",
data: '<MyReq user="' + User + '" katha="' + ivalitiKatha + '" />',
success: function(data) {
},
error : function() {
alert("Sorry, The requested property could not be found.");
}
});
});
</script>
</body>
</html>
这是我在服务器端的web.xml
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/ajax/*</url-pattern>
</servlet-mapping>
$阿贾克斯代码对我的作品!当我在Jquery所在的页面上使用您的代码时,发送请求!您可以通过将代码复制到萤火虫控制台并执行它来尝试。你的$ .ajax代码不是问题 – 2012-08-07 07:56:20
'User'和'ivalitiKatha'在哪里?也许是因为那些没有定义的变量? – 2012-08-07 08:31:37