Jquery 外部位置上对webservice的ajax调用
您好,我正在为liferay开发portlet,我正在尝试调用webservice。我知道我必须在jquery中支持CORS,但即使定义了CORS,我也只能从带有IE9(????)的webservice获得响应。Chrome和mozilla只是没有反应 这是我的代码:Jquery 外部位置上对webservice的ajax调用,jquery,ajax,web-services,liferay,Jquery,Ajax,Web Services,Liferay,您好,我正在为liferay开发portlet,我正在尝试调用webservice。我知道我必须在jquery中支持CORS,但即使定义了CORS,我也只能从带有IE9(????)的webservice获得响应。Chrome和mozilla只是没有反应 这是我的代码: jQuery.support.cors = true; AUI().ready(function(){ Liferay.on('senduid', function(data){ var uid=data.da
jQuery.support.cors = true;
AUI().ready(function(){
Liferay.on('senduid', function(data){
var uid=data.data;
var v="1.0";
var q="dojo toolkit";
$.ajax({ url: 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=dojo%20toolkit', data: "&v="+v+"&q="+q, dataType: 'json', success: function(data){
alert('here...success');
},
// complete: function (data) {
// alert('here');
// }
});
});
});
正如我所说,警报“此处成功”仅出现在IE中
有人能帮我怎么做吗
PS:webservice应该发送如下内容:
"pages": [
{
"start": "0",
"label": 1
},
{
"start": "4",
"label": 2
}, ...
谢谢您遇到了跨域问题。我猜IE浏览器中的安全设置不允许跨域调用。如果您将数据类型值更改为“jsonp”,这将起作用 我让它在JSFIDLE中工作:
var uid = 'test';
var v = "1.0";
var q = "dojo toolkit";
$.ajax({
url: 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=dojo%20toolkit',
data: {
"v": v,
"q": q
},
dataType: 'jsonp',
success: function (data) {
alert('here...success');
}
});