2013-08-17 32 views
0

我试图编写一个代码,以便从xmlhttprequest获取的响应中提取“代码”。我来到这里了。如何使用jquery从xmlhttprequest获取类属性

enter image description here

我新来的JavaScript和jQuery,是我提取像扣右“ADDIDIONAL25”作为展会的代码的方法吗?有没有更好的方法来做到这一点?我打算从快照中显示的数组中提取“代码”。

+0

看起来好像没什么问题。但是,SO不适合这样的问题。如果您有具体问题,我们很乐意提供帮助。 –

回答

1

尝试

var codes = $('.coupon_code_text', req.responseText).map(function(){ 
    return $(this).attr('code') 
}).get(); 
console.log(codes)//it is an array containing all the code values