我尝试从另一个服务器加载静态html页面。我发出跨域请求。
$(document).ready(function (){
$("div[src]").each(function(){
var staticFileURL = $(this).attr('src');
$.ajax({
url: staticFileURL,
dataType: 'jsonp',
data: {},
error: function(xhr, status, error) {
alert(error);
},
success: function() {
alert("success");
},
jsonp: false,
jsonpCallback: 'jsonpCallback'
});
});
});
但是我得到了chrome错误“语法错误:意外的标记<”。
在FF“语法错误:无效的xml属性值”中。什么是wrong.Could ?谁来帮帮我?
发布于 2012-07-16 21:49:06
JSONP是从服务器获取json数据,看起来你是在尝试接收HTML数据。尝试将HTML数据放入服务器上的JSON对象中,然后在成功回调中读取该HTML:
例如,来自服务器的json数据:
{ html: "<html><head>...</head></html>" }
此外,您的成功回调应该如下所示:
success: function(**data**){ }
https://stackoverflow.com/questions/11505634
复制相似问题