我在site1.com上有一个PHP脚本,它返回HTML。比方说,它http://site1.com/script.php和回报:显示来自其他站点的HTML
<div id="test"><img src="path"/></div>
我想收到并显示HTML上site2.com
AJAX。 jQuery的。
$.ajaxSetup({
crossDomain: true,
dataType: "jsonp text html" //like documentation said
});
$.get("http://site1.com/script.php", { param: param}, function(data) {$("#some_id").html(data);})
而且我收到错误:
Uncaught SyntaxError: Unexpected token < in http://site1.com/script.php line 1
我试过很多的数据类型。什么都没有 如何使它工作?
我不能用在site2.com
看来你的错误来自其他地方。它基本上说,你的脚本中有一个'<'不应该在那里。 – Artyom 2012-02-13 13:57:26
试试这个。 http://james.padolsey.com/javascript/cross-domain-requests-with-jquery/ – 2012-02-13 13:59:47