我知道很多話題都存在,但是我沒有找到解決我的問題的方法。 我做了一個AJAX請求,我想分析結果,並將其注入到我的頁面中的表中。用jquery解析AJAX結果
$.ajax({
type : "GET",
url : "http://keyserver.gingerbear.net/pks/lookup?",
data : "[email protected]&fingerprint=on&op=index",
dataType: "html",
success : function(resultat){
$(resultat).ready(function() {
$('pre',$(resultat).html()).each(function(){
var htmlString = $(this).html();
console.log("Key ID : "+/0x[a-z0-9]{16}/i.exec(htmlString));
console.log("User : "+$(this).find('a:eq(1)').text());
console.log("Bits : "+/[0-9]{4}[RD]/.exec(htmlString));
console.log("Data : "+/[0-9]{4}-[0-9]{2}-[0-9]{2}/.exec(htmlString));
console.log("Fingerprint : "+/Fingerprint=(.*)/.exec(htmlString));
});
});
},
// Blabla
});
我看到here解決方案的開始。例如,我可以做console.log($(resultat).find('a')),我有第一個的內容,但是console.log($(resultat).find('pre'))沒有工作...
你可以給一個'reultat'的樣本值嗎? – nmenego 2013-04-11 14:00:10
是的,resultat包含此頁面的內容,在我的示例中:keyserver.gingerbear.net/pks/[email protected]&fingerprint=on&op=index – 2013-04-11 14:42:18