我想通過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