jQuery.support.cors = true;
var URL = 'http://blahblah:5555/blahblahWS';
$.ajax({
type: 'POST',
url: URL,
dataType: 'html',
success: function(data, status){
alert(data.responseData.results.length + ' results found!');
$('#curr').wrapInner('<span class="icon green">q</span>');
},
error: function() {
$('#curr').wrapInner('<span class="icon red">r</span>');
}
});
FYI, jQuery.support.cors = TRUE;需要调用本地服务, 类型是义务后,web服务调用返回错误
我喜欢基于Web服务的调用回复显示绿色或红色图标, 它总是给我的错误,唐诺为什么
,但是当我通过尝试这
jQuery.support.cors = true;
$("#success").load("http://blahblah:5555/blahblahWS", function(response, status, xhr) {
if (status == "error") {
var msg = "Sorry but there was an error: ";
$("#error").html(msg + xhr.status + " " + xhr.statusText);
}
if (status == "success") {
var msg = "no error ";
$("#success").html(msg + xhr.status + " " + xhr.statusText);
}
});
这说明200 OK响应
说 您好!这是一个Axis2 Web服务!
有什么区别,我如何纠正它在#.ajax()?
你有权访问blahblah上的日志吗?你能确认请求实际上到达那里吗? – malonso 2012-02-12 15:06:01
前者的错误信息是什么? – supertopi 2012-02-12 15:07:04
它显示200 OK响应 说你好!这是一个Axis2 Web服务! – cypronmaya 2012-02-12 15:09:40