ajax问题,下面的代码有什么问题? 本帖最后由 huangwanfeng9 于 2014-03-09 10:20:11 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 httpRead("http://www.biquge.com/0_360/157267.html");这里怎么用的静态的网页,静态网页可以作为ajax请求的目标吗?这个我还真是不清楚,但是按我的想法,应该不行吧。还有一个可能的问题,就是跨域问题了,你的发出请求的页面,是不是在www.biquge.com这个域名下。 前台搞不了,浏览器的javascript搞不了 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></script><script>// jquery.xdomainajax.js ------ from padolseyjQuery.ajax = (function(_ajax){ var protocol = location.protocol, hostname = location.hostname, exRegex = RegExp(protocol + '//' + hostname), YQL = 'http' + (/^https/.test(protocol)?'s':'') + '://query.yahooapis.com/v1/public/yql?callback=?', query = 'select * from html where url="{URL}" and xpath="*"'; function isExternal(url) { return !exRegex.test(url) && /:\/\//.test(url); } return function(o) { var url = o.url; if ( /get/i.test(o.type) && !/json/i.test(o.dataType) && isExternal(url) ) { // Manipulate options so that JSONP-x request is made to YQL o.url = YQL; o.dataType = 'json'; o.data = { q: query.replace( '{URL}', url + (o.data ? (/\?/.test(url) ? '&' : '?') + jQuery.param(o.data) : '') ), format: 'xml' }; // Since it's a JSONP request // complete === success if (!o.success && o.complete) { o.success = o.complete; delete o.complete; } o.success = (function(_success){ return function(data) { if (_success) { // Fake XHR callback. _success.call(this, { responseText: data.results[0] // YQL screws with <script>s // Get rid of them //.replace(/<script[^>]+?\/>|<script(.|\s)*?\/script>/gi, '') }, 'success'); } }; })(o.success); } return _ajax.apply(this, arguments); };})(jQuery.ajax);$.ajax({ url: 'http://www.biquge.com/0_360/157267.html', type: 'GET', success: function(res) { var text = res.responseText; // then you can manipulate your text as you wish alert(text); }});</script></head><body></body></html> 关于index索引的问题 My97DatePicker如何 去掉 最下面的 确定 按扭 高手帮忙看下这段JS脚本,帮我修改一下 js里动态创建了一个img 并且添加了他的click事件,我在其他地方如何也调用这个img的click事件? 在线等 求解 一个404错误 这句怎么写?在线等 关于文字滚动效果,我也有问题!!!请大家来看看 ocx与javascript:参数类型(olevariant)在js中如何处理?(100分) 如何去掉ie工具栏,状态栏 刚才没说清楚,这次争取说清楚一点 关于jQuery的ajax调试问题 正则表达式问题
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></script>
<script>
// jquery.xdomainajax.js ------ from padolseyjQuery.ajax = (function(_ajax){ var protocol = location.protocol,
hostname = location.hostname,
exRegex = RegExp(protocol + '//' + hostname),
YQL = 'http' + (/^https/.test(protocol)?'s':'') + '://query.yahooapis.com/v1/public/yql?callback=?',
query = 'select * from html where url="{URL}" and xpath="*"'; function isExternal(url) {
return !exRegex.test(url) && /:\/\//.test(url);
} return function(o) { var url = o.url; if ( /get/i.test(o.type) && !/json/i.test(o.dataType) && isExternal(url) ) { // Manipulate options so that JSONP-x request is made to YQL o.url = YQL;
o.dataType = 'json'; o.data = {
q: query.replace(
'{URL}',
url + (o.data ?
(/\?/.test(url) ? '&' : '?') + jQuery.param(o.data)
: '')
),
format: 'xml'
}; // Since it's a JSONP request
// complete === success
if (!o.success && o.complete) {
o.success = o.complete;
delete o.complete;
} o.success = (function(_success){
return function(data) { if (_success) {
// Fake XHR callback.
_success.call(this, {
responseText: data.results[0]
// YQL screws with <script>s
// Get rid of them
//.replace(/<script[^>]+?\/>|<script(.|\s)*?\/script>/gi, '')
}, 'success');
} };
})(o.success); } return _ajax.apply(this, arguments); };})(jQuery.ajax);$.ajax({
url: 'http://www.biquge.com/0_360/157267.html',
type: 'GET',
success: function(res) {
var text = res.responseText;
// then you can manipulate your text as you wish
alert(text);
}
});
</script>
</head>
<body>
</body>
</html>