如何使用jquery:1-读取一个特定的URL将特定的XHTML标记值存储到数组中3 .将这个数组传递给PHP脚本
这些是标签
<img class="nytmm_slidingMultimedia_imageSlide" style="display: inline; height: 620px; width: 930px;" src="http://graphics8.nytimes.com/images/2011/02/28/world/africa/20110301_LIBYA-slide-FBZQ/20110301_LIBYA-slide-FBZQ-jumbo.jpg">
在上面的标签中,我想将SRC列表存储到数组中(可能有不同SRC的img标签)
<div class="nytmm_bigPhotoGallery_caption">Residents of Sabratha rallied in support of Colonel Qaddafi in front of a bank where they were waiting to receive a one-time 300 Dinar bonus offered to every Libyan citizen by the regime.</div>
在上面标记的中,我想将div中的值或文本存储到另一个数组中(可能有不同内容的div标签)
然后我想把这两个数组传递给PHP,这样我就可以处理剩下的任务了
thanks and regards
var requestData = {}; // data object for future ajax request
requestData.src = []; // array for storing your src values
// getting multiple src values
$('.nytmm_slidingMultimedia_imageSlide').each(function(index){
requestData.src.push($(this).attr('src'));
});
// getting single div text, be sure that there is only one div selected
requestData.text = $('.nytmm_bigPhotoGallery_caption').first().text();
// make an ajax request
$.post( 'some/handler.php', requestData, function(response) { console.log(response)} );
这里只有一些关于如何获得单个值和乘法的例子。