为什么我的jquery AJAX调用Web服务没有返回任何数据?当我打电话给我的网络服务时为什么没有发生?为什么我的Web服务客户端不能在不同的服务器/域上使用Web服务?
我花了相当多的时间研究如何让我的jquery UI应用程序在另一个域上使用Web服务.我终于弄清楚了,并且正在为今后遇到这一挑战的任何人记录细节.注意,我正在对JBOSS v4容器中托管的一组Documentum DFS POJO Web服务使用jquery $ .ajax调用.较新版本的Tomcat/JBOSS使这一过程变得更加容易.
这是等式的jquery方面:
<script type="text/javascript">
var tjson;
var webServiceURL = 'http://hostname/services/pDFS/atlContractService';
var soapMessage;
$(document).ready(function() {
jQuery.support.cors = true;
});
function onSaveTitleData() {
soapMessage = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.prodagio.com"><soapenv:Header/><soapenv:Body><ser:saveProjectData><prjInfo>' + tjson + '</prjInfo></ser:saveProjectData></soapenv:Body></soapenv:Envelope>';
CallService();
}
function CallService()
{
$.ajax({
url: webServiceURL,
type: "POST",
dataType: "xml",
data: soapMessage,
processData: false,
contentType: "text/xml; charset=\"utf-8\"",
success: OnSuccess,
error: OnError
});
return false;
}
function OnSuccess(data, status)
{
alert(data.d);
}
function OnError(request, status, error)
{
alert(request + status …Run Code Online (Sandbox Code Playgroud)