我的ajax(jquery)响应(html)给了我一大堆html源代码,因为它获取了enrite页面.
响应有点像下面:
<html>
<head>
...
...
</head>
<body>
.
.....
.
.......
<div id="content">
content i want to extract
</div>
.............
..........
.............
</body>
</html>
我需要以下方面的帮助:
1)是否可以阅读之间的任何内容<div id='content'></div>?如果有,怎么样?
2)如果#1不可能,我怎样才能从中提取内容<div id='content'></div>?
我试过的代码:
/*Ajax*/
$jq(function(){
alert ("Doc ready");
$jq("#content a.next-page").bind("click", function(e){
alert ("Hey!");
/*Make the call*/
$jq.ajax({
url: "/page/2",
type: "get",
cache: false,
data: "",
error: function(){alert ("No data found for your search.");},
success: function(results){
//$searchPanel.find("tbody").empty().append(results);
//$searchPanelHolder.css({"display":"block"});
alert (results.find("div[id='content']").html());
e.preventDefault();
}
});
e.preventDefault();
});
});
对此有任何帮助非常感谢
非常感谢,Racky
我有一个定制的MVC PHP框架,我正在重写,并对性能和魔术方法有疑问.使用框架的模型部分,我在想是否__get/ __setmagic方法会导致太多的性能损失值得使用.我的意思是访问(读取和写入)模型数据将是最常见的事情之一.对于像MVC框架的模型部分这样的大量使用功能,__get/ __setmagic方法的使用是否太大了?
我通过PHP及其方法imap_open获取了我在GMail帐户中的未读邮件
当我通过方法imap_fetch_overview得到主题时,我得到一些这样的主题:
=?ISO-8859-1?Q?Informaci=F3n_Apartamento_a_la_Venta?= =?ISO-8859-1?Q?_en_Benasque(Demandas:_0442_______)?=
Run Code Online (Sandbox Code Playgroud)
这是不可读的,我认为是因为它的字符编码.
我该怎么做才能使它具有可读性?
我有一个阵列
var array = ["google","chrome","os","windows","os"];
Run Code Online (Sandbox Code Playgroud)
我想删除"chrome"数组中的值而不将数组变为字符串.有没有办法做到这一点?
生产VariableStatement:
var VariableDeclarationList ;
Run Code Online (Sandbox Code Playgroud)
评估如下:
VariableDeclarationList.(normal, empty, empty).我想知道正常和空洞的含义.
我有一个发送一些数据的 AJAX 请求。数据遵守 multipart/form-data规范。
我面临的问题是浏览器将 Content-Type 标头设置为 text/plain,它应该是 multipart/form-data。
我试过这样做:request.setRequestHeader("Content-Type", "multipart/form-data");但这给出了 400 Bad Request 错误。
如果我这样做request.setRequestHeader("Content-Typexxxx", "multipart/form-data");没有错误,则设置了“Content-Typexxxx”标头,但显然对我没有帮助。
我想有一个可以设置的有效 Content-Type 标头列表,并且“multipart/form-data”不在其中,但我找不到解决我的困境的方法。
实际发送的数据示例:
内容类型:多部分/表单数据;边界=l3iPy71otz --l3iPy71otz 内容配置:表单数据;名称=“标题公共” Variation_1 --l3iPy71otz 内容配置:表单数据;名称="nr_versiune" --l3iPy71otz--
谢谢!
我通过 Greasemonkey 脚本/opera 扩展将以下代码注入到网页中以捕获该history.pushState命令,这样我就可以在它触发时进行一些处理,并且仍然允许该pushState命令在之后继续。
(function(history){
var pushState = history.pushState;
history.pushState = function(state) {
if (typeof history.onpushstate == "function") {
history.onpushstate({state: state});
}
alert('pushstate called')
return pushState.apply(history, arguments);
}
})(window.history);
Run Code Online (Sandbox Code Playgroud)
该代码在 FF4 和 Chrome 中工作正常,但在 Opera 11 中,如果页面调用命令,我会收到以下错误history.replaceState:
未捕获的异常:TypeError:'window.history.replaceState'不是函数
有谁知道如何修复上述代码以与 Opera 以及 Chrome 和 Firefox 一起使用?
我需要一个正则表达式进行字符串验证.字符串可以为空,可以有5位数,也可以有9位数.其他情况无效.我正在使用下一个正则表达式:
/\d{5}|\d{9}/
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
我只是在使用javascript的问题我正在使用asp.net上的代码,经过几个小时的计算后,它变成了逃避字符的问题.
起初我用这个.
ScriptManager.RegisterStartupScript(this, this.GetType(), "temp", "alert('Can't delete this data because it is bound with rate plan');", true);
Run Code Online (Sandbox Code Playgroud)
这将导致javascript错误,因为"不能"的引用需要使用转义字符,所以我使用.
ScriptManager.RegisterStartupScript(this, this.GetType(), "temp", "alert('Can\'t delete this data because it is bound with rate plan');", true);
Run Code Online (Sandbox Code Playgroud)
但它仍然无效.
我终于用了
ScriptManager.RegisterStartupScript(this, this.GetType(), "temp", "alert('Can\\'t delete this data because it is bound with rate plan');", true);
Run Code Online (Sandbox Code Playgroud)
这很好.
我只是好奇为什么我们需要使用\\'而不是\'为了使转义字符正常工作.
我和ExtJS只工作了2周.我的所有代码看起来都像一个大文件.我在代码中包含许多面板和其他ExtJS对象.看起来像一棵大树)可以为定义,存储JS文件的代码部分提供一些简单的建议吗?