how to get the value of an php array in jQuery

Posted by user1933824 on Stack Overflow See other posts from Stack Overflow or by user1933824
Published on 2013-10-20T03:14:07Z Indexed on 2013/10/20 3:54 UTC
Read the original article Hit count: 103

Filed under:
|
|

i have a PHP code that will obtain the total images of a certain website via CURL, and put it inside an PHP loop.

$z=1;
for ($i=0;$i<=sizeof($images_array);$i++) {
    ....<img src = "$images_array[$i]" id="$z"> ..
    $z++;
    }

a user can then scan through the array with a prev/next button and the current image being shown will be displayed in my $('$current_image').val(1);

$.post("curl_fetch.php?url="+ extracted_url, {
    }, function(response){
    $('#loader').html($(response).fadeIn('slow'));
    $('#current_image').val(1); // insert loop value in .val()

when i click a button, i want to get the value of the array, and not the loop value

$(function() {
    $(document).on('click','.submit', function () {
    var img = $('#current_image').val(); //get the array value, not the loop value
    alert(img);
});});

now, how do i properly get the array value in my $('#current_image').val(1); in Jquery.

© Stack Overflow or respective owner

Related posts about php

Related posts about jQuery