开发者

what methods are available on something of type Object #<Text>

I'm still befuddled by the NodeList object in Mootools, and I'm hoping someone can help clarify.

I'm making a simple HTML request using Request.HTML. Here's the code:

var req = new Request.HTML({
  url: my_url,
  onSuccess: function(response) { alert(response) }
});
req.send();

On the server side, I'm just rendering some text ("here's a response", specifically). The alert shows "[oject NodeList]", and I'm wondering what methods I can call on it to get the alert to show "here's a response".

I know that alert(response[0]) shows "[object Text]". I also figured out that开发者_开发知识库 if I put a break line right in the middle of my onSuccess function and type (in the console) response[0] + enter, it show's my "here's a response" text. I just can't figure out how to get the alert to show "here's a response"....

Thanks


from the mootools docs:

onSuccess(responseTree, responseElements, responseHTML, responseJavaScript)

looks like you want the third argument in the onSuccess callback function. so back to your example:

var req = new Request.HTML({
  url: my_url,
  onSuccess: function(responseTree, responseElements, responseHTML) {
    alert(responseHTML)
  }
});
req.send();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜