jQuery:查询 $.get() 返回的字符串 [英] jQuery: query a $.get() returned string

查看:34
本文介绍了jQuery:查询 $.get() 返回的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何查询通过 $.get 得到的字符串?例如,我只想要表单 google 的正文 html:

How can i query a string i get via $.get? for example, i want form google only the body html:

$.get("www.google.com", function(data){
var body = $("body", data).html(); //This doesnt work
});

有可能吗?谢谢

推荐答案

不,jQuery 不能直接访问通过 XmlHttpRequest 加载的页面的 DOM.为此,您必须使用用 JavaScript 编写的 HTML 解析器,例如 John Resig 写的那个.不过,这仍然比您预期的要困难得多.

Nope, jQuery can't directly access the DOM of a page that was loaded via an XmlHttpRequest. In order to do this, you would have to use an HTML parser written in JavaScript, like the one that John Resig wrote. It's still a much harder task than you were probably expecting though.

这篇关于jQuery:查询 $.get() 返回的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆