jQueryを使用してjs内でJavaメソッドを呼び出そうとしています。呼び出しは実際には Fiddler で証明されているように機能していますが、jQuery エラー メソッドが常に呼び出され、応答を取得できません。なぜこれが起こっているのか分かりません。これはクロスドメイン呼び出しである可能性がありますが、実際には成功しており、Fiddler から xml 応答を取得できます。おそらく、ajaxメソッドのタグが間違っているだけだと思います。私の「データ」は、私が見る限り、配列または名前/値のペアではなく、送信される単なるxmlの文字列です。私は何か見落としてますか?
var jqxhr = $.ajax({
type: "POST",
url: userManagementUrl,//the js call version of this
data: '<?xml version="1.0" encoding="UTF-8"?><WebClientRequest xmlns="http://xsd.rt.state.id.us/usermanagerservice" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><requestMethodList><requestRights><userName>' + $("#loginUsername").val() + '</userName><password>' + $("#loginPassword").val() + '</password></requestRights></requestMethodList></WebClientRequest>',
//async: false,
//contentType: "text/xml",
dataType: "xml",
//crossDomain: true,
success: function (xml) {
if (xml) {
//parse through the xml response looking for status
var node = $(xml).find("result").text();
if (node) {
if (node === "success") {
boolLoggedIn = true;
$("#loginDialog").dialog("close");
}
else {
boolLoggedIn = false;
alert("login failed");
}
}
else {
console.log("could not find result node");
}
}
else {
console.log("error logging in");
}
},
error: function (jqXHR, textStatus, errorThrown) {
console.warn("error in login call");
$("#txtLoginStatus").html("<b>Login failed!</b>");
boolLoggedIn = false;
}
});
jqxhr.done(function (result) {
console.log("Logged In");
$("#loginDialog").dialog("close");
});
jqxhr.always(function (result) {
console.log("Logged In");
$("#loginDialog").dialog("close");
});
jqxhr.then(function (result) {
console.log("Logged In");
$("#loginDialog").dialog("close");
});
});