I would like to get a particular part of the Ajax response and put this text in a variable. In this case var number. When I use this code the alert comes up null.
jQuery(function(){
jQuery('a.productnamecolor.colors_productname').each(function(){
var star_link = jQuery(this).attr('href');
jQuery.ajax({
url: star_link,
type: 'POST',
cache: false,
success: function(data){
var number = $(data).find("#pt691").text();
alert(number);
}
})
});
});
Below is just a small portion of the total response that is returned. I want to capture the "2" in the span id pt691 and put that in the variable number. Does .text() not work in this case?
开发者_运维百科<span class="PageText_L691n">Based on <span id="pt691">2</span> reviews </span>
Seems to work OK for me http://jsfiddle.net/K7VBp/1/ and I can use .text()
or .html()
with equal success. Can we see the full result of your data
variable?
精彩评论