我有一个用户脚本,通过GM_xmlhttprequest触发ajax调用,将带有文本和链接的简单页面加载到名为“debug”的div中。这工作得很好。现在我想要通过gm_xmlhttprequest请求所请求文档中的每个链接。我不知道为什么我的功能无法正常工作来自ajax请求的链接不通过ajax请求
$('.ajax, .ajaxn').click(function(event) {
event.preventDefault();
var href = $(this).attr('href');
GM_xmlhttpRequest({
method: "GET",
url: href,
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
onload: function(response) {
$('#debug').html('');
$('#debug').append(response.responseText).fadeIn(5000);
}
});
});
响应中的链接有类ajaxn,和萤火虫的DOM/HTML面板显示的响应实际上是插入#调试
任何提示?
你说“响应实际上被插入#debug”。那么有什么不工作? – wimh 2013-03-26 11:11:33
我认为你通过调用'$('#debug')。html('');'来移除所有以前的内容。尝试一下'console.log'来确定是否所有的xmlHttpRequests都被执行了? – Laoujin 2013-03-26 12:44:12