ajax - jquery read text from html, multiple classes -
ajax - jquery read text from html, multiple classes -
i have 5 different name div's, has different id. first div once, sec divs 1-5 times , other 3 div's, never know how many more 10 times in whole body.
and need read them through jquery (loop) way save every so-called line line jquery repeat process until have been read , saved. , every time 5 div's
the third-, fourth-, 5th div, same amount,
with code 1 div info.
var kuupaev = ""; $('.page .sub').each(function(){ kuupaev = $(this).text(); $.ajax({ url: 'save.php', type: 'post', data: {kuupaev:kuupaev}, success: function (data) { callback(data); } }); });
maybe can help me. big give thanks you
sorry bad english...
edit: figured out..
<script> for(var index = 0; index < $(".page_channel").nextuntil(".page_channel").andself().length; index++) { /* var pikkus = $(".page_channel").nextuntil(".page_channel").andself().length; alert(pikkus) */ var kanal = $('.page_channel .1').first().text(); var kuupaev = $('.page_channel .2').first().text(); var kell = $('.page_channel .3').eq(index).text(); var sisu_pilt = $('.page_channel .4').eq(index).val(); var pealkiri = $('.page_channel .5').eq(index).text(); $.ajax({ url: 'save.php', type: 'post', data: {kuupaev:kuupaev,kanal:kanal,kell:kell,pealkiri:pealkiri,sisu_pilt:sisu_pilt}, success: function (data) { callback(data); } }); } </script>
you pass multiple parameters info parameters, next example:
$.ajax({ url: 'save.php', type: 'post', data: { div1: 'info div1', div2: 'info div2', div3: 'info div3', div4: 'info div4', div5: 'info div5' }, datatype: 'json' success: function(data) { callback(data); } });
then can div info using jquery follows:
var div1 = $("#div1").text(); var div2 = $("#div2").text(); var div3 = $("#div3").text(); var div4 = $("#div4").text(); var div5 = $("#div5").text();
to tie together, have pass variables info array
data: { div1: div1, div2: div2, div3: div3, div4: div4, div5: div5, },
jquery ajax
Comments
Post a Comment