MooTools:如何直接使用responseText
在下面的代码示例中,我想遍历responseText对象,其中包含来自request_page.php文件的html代码。在 onSuccess 事件中,我想检查是否 <分区> id 'ersDiv' 中发布了任何错误。
new Request.HTML({
url: 'request_page.php',
onSuccess: function(responseText, responseXML) {
// My expected code to handle responseText object
alert(errorMessage);
},
onFailure: function() { }
});
request_page.php 文件是这样的:
<div align='center'><div id='ersDiv'>Page loaded with insufficient data</div></div>
In following example of code, I want to traverse the responseText object which consist the html code came from request_page.php file. In onSuccess event, i want to check whether < Div > with id 'ersDiv' has any errors posted in it.
new Request.HTML({
url: 'request_page.php',
onSuccess: function(responseText, responseXML) {
// My expected code to handle responseText object
alert(errorMessage);
},
onFailure: function() { }
});
request_page.php file is like this :
<div align='center'><div id='ersDiv'>Page loaded with insufficient data</div></div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 1.2.x 上尝试一下(针对 jsfiddle api 进行调整的示例):
工作示例:
http://www.jsfiddle.net/dimitar/vLgqB/" jsfiddle.net/dimitar/vLgqB/
在 1.3 中,这可以按照 oskar 的建议工作:
http ://www.jsfiddle.net/dimitar/vLgqB/2/
玩得开心。
try this for 1.2.x (example tweaked for the jsfiddle api):
working example:
http://www.jsfiddle.net/dimitar/vLgqB/
in 1.3 this can work as oskar suggested:
http://www.jsfiddle.net/dimitar/vLgqB/2/
have fun.
顺便提一句。 1990 年召唤而来,他们希望
align='center'
回来:-)Btw. 1990 called, they want their
align='center'
's back :-)