【发布时间】:2010-06-26 20:40:15
【问题描述】:
您好,我正在做一个练习,我正在尝试使用 javascript/ajax 抓取 nytimes 网站的内容。
为了发送跨域 ajax 请求,我使用了一个代理服务器,它返回带有 nytimes 网站内容的 jsonp 响应。
但由于该 html 内容有一些字符(单引号)会引发“非法字符”错误。
<script type="text/javascript" src="http://json-proxy.jgate.de/?callback=callback&url=http%3A%2F%2Fwww.nytimes.com%2F"></script>
<script>
function callback(obj) {
alert(obj);
}
</script>
有什么办法可以解决这个错误? 还有什么其他方法可以解决这个问题?
谢谢
(p.s. 这个问题是在我的一位朋友采访中问他的)
更新:这里是相同的雅虎管道链接。 http://pipes.yahoo.com/pipes/pipe.run?_id=748e37c218ed0747d0b868ae8eafefa6&_render=json
【问题讨论】:
标签: ajax cross-domain jsonp illegal-characters