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

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

问题描述

我如何查询字符串我通过$不用彷徨得到什么呢?例如,我想形成谷歌只是身体的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
});

它甚至有可能吗? 谢谢

Is it even possible? thanks

推荐答案

不,jQuery的不能直接访问已通过XmlHtt prequest加载一个页面的DOM。为了做到这一点,你将不得不使用JavaScript编写一个HTML解析器,如的一个约翰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的:查询$。获得()返回的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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