[英]Call Webservice with jQuery Ajax
我正在尝试使用jquery.ajax调用我的Web服务。
jQuery.support.cors = true;
$.ajax({
type: 'POST',
url: wsUrl,
contentType: "text/xml; charset=utf-8",
dataType: "xml",
cache: false,
crossDomain: true,
data: soapRequest,
success: reqSuccess,
error: reqError
});
我收到“访问被拒绝”错误和状态/ readyState 0。
如果我使用SoapUI向我的Web服务发出请求,它会很好地工作。
发出SOAP请求时,请确保将processData
设置为false
以防止jQuery将XML请求转换为字符串。
$.ajax({
type: 'POST',
url: wsUrl,
contentType: "text/xml; charset=utf-8",
dataType: "xml",
cache: false,
crossDomain: true,
data: soapRequest,
processData: false,
success: reqSuccess,
error: reqError
});
从文档中: http : //api.jquery.com/jQuery.ajax/
processData (default: true)
Type: Boolean
By default, data passed in to the data option as an object (technically, anything
other than a string) will be processed and transformed into a query string, fitting
to the default content-type "application/x-www-form-urlencoded". If you want to send
a DOMDocument, or other non-processed data, set this option to false.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.