[Solved] Php variable not getting incremented in jquery


Fixed session issue :

$.ajax
    ({
        url : "test.php",
        type : "post",
        data : {
            "categoryIds" : categoryIds
        },
        dataType : "json",
        success : function(resp){
            var html = "";
            var i = 1;
            <?php $j = 1; ?>
            $.each(resp,function(key,questions ){
               var testdataIndex  = "answer_" + i ;
               var  filename = "getsession.php?sessionName="+testdataIndex;
               $.get(filename, function (data) 
                     {
                        sessionValues = data;
                        $("#"+testdataIndex).text(sessionValues);
               });//get
               html += '<textarea class="form-control answer"  rows = "5"  style="width:127%;" id="answer_'+i+'" name="answer_'+i+'" required="required"></textarea>';
              i++;
      });//each
});//ajax

getsession.php

<?php
session_start();
$sessionName = $_GET['sessionName'];
print ($_SESSION['testdata'][$sessionName]);
?>

I have answered my question for other who face same problem.

solved Php variable not getting incremented in jquery