Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用jquery从xmlhttprequest获取类属性_Javascript_Jquery_Ajax_Arrays - Fatal编程技术网

Javascript 如何使用jquery从xmlhttprequest获取类属性

Javascript 如何使用jquery从xmlhttprequest获取类属性,javascript,jquery,ajax,arrays,Javascript,Jquery,Ajax,Arrays,我试图编写一个代码,从xmlhttprequest获得的响应中提取“代码”。我已经走了这么远 我不熟悉javascript和jquery,我提取快照中显示的“AddDional25”之类代码的方法对吗?有更好的方法吗?我计划从snap中显示的数组中提取“代码”。试试看 var codes = $('.coupon_code_text', req.responseText).map(function(){ return $(this).attr('code') }).get(); con

我试图编写一个代码,从xmlhttprequest获得的响应中提取“代码”。我已经走了这么远

我不熟悉javascript和jquery,我提取快照中显示的“AddDional25”之类代码的方法对吗?有更好的方法吗?我计划从snap中显示的数组中提取“代码”。

试试看

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

我觉得不错。但这并不是提出此类问题的合适场所。如果您有具体问题,我们很乐意提供帮助。