how can i use jquery todo: 1- read a specific URL 2- store a specific xhtml tag values into an array 3- pass this array to PHP script
these are the tags
<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">
in the above tag i want to store a list of src into an array ( there are may img tags with different src )
<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>
in the above tag i want to store the value or the text inside the div into another array ( there are may开发者_JS百科 div tags with different content )
then i want to pass those 2 arrays to php where i can manage to do the rest of the tasks.
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)} );
There is only some examples of how to get single value and multiply.
精彩评论