php - Jquery doesn't get the unique ID after an ajax post request -




i've been struggling find solution problem 3 weeks now, have html table data populated through mysql query, , update database through jquery ajax post method, there no problem during initial load of page, can unique id , validate through bootstrap modal, however, problem after first post method when redirect table, of unique id converted on id first posted..so of data extracted base on id, should not way since want target unique id through 'click pay cash advance' button..can me glitch is?

here code html table

    $cashadvances = array(); $x = 0;     $department = $_post['department'];     $fromstart = $_post['fromstartdepartment'];     $toend = $_post['toenddepartment'];  <div id="tabledepartment">        <table class="table table-bordered table-condensed" id="<?=      'departmenttable'; ?>" >     <tr bgcolor = "#2c3e50">            <th><font color="white"> company id</th>            <th><font color="white">department</th>            <th><font color="white">name</th>            <th><font color="white">date covered</th>            <th><font color="white">cash advance</th>            </tr>        <?php $data = array();                   $datecovered = $fromstart.'to'.$toend;            ?>            <?php while($result =            mysqli_fetch_array($resultquerydepartment)): ?>                     <?php $cashadvances[] += $result['company_id'];                     $data[] = array('id'=> $result['company_id'],                                     'department'=>$result['department'],                                    'name'=>$result['name'],                                    'datecovered' =>$datecovered,                        'cashadvancecredit' =>               $resultattendancepayroll['salary'],                        'duration' => 'weekly'                     );                    $json_data = json_encode($data);                    $mydir = 'json';                      if(!file_exists($mydir)){                        $oldmask = umask(0);//helpful when used in linux                         mkdir($mydir, 0777);                    }          file_put_contents($mydir.'/resultscashissuancedepartment.json',        $json_data);             ?>     <?php while($result = mysqli_fetch_array($resultquerydepartment)): ?>     <tr></tr>     <td></td>     <td></td>     <td></td>     <td></td>     <td>     <a data-statename="<?= $result['company_id']; ?>" id="susubukan"><button      type="button"  id="modalindividualondepartment"  value="<?=      $result['company_id']; ?>" class="btn btn-primary edit_data"   data-     toggle="modal" data-target="#modalindividualdepartment"                 <?php                 if(($resultcashadvancebyindividualondepartment) ||       ($resultfullypaidindividualondepartment == '0')){                     echo 'disabled';                 }else{                     echo '';                 }                   ?>                   >click pay cash advance</button></a>     </td></tr> <?php endwhile; ?> </table> </div> 

here modal validation

<div class="modal fade" id="modalindividualdepartment" tabindex="-1"  role="dialog"> <div class="modal-dialog" role="document"> <div class="modal-content">   <div class="modal-header">     <button type="button" class="close" data-dismiss="modal" aria- label="close"><span aria-hidden="true">&times;</span></button>     <h4 class="modal-title">individual payment</h4>   </div>   <div class="modal-body" id="dataondepartment">    </div>   <div class="modal-footer">          </div>     </div>   </div> </div> 

here javascript process data on modal

$('a[data-statename]').on('click', function(){ var id = "";  id = $(this).attr("data-statename"); //console.log(id);  $('#modalindividualdepartment').on('show.bs.modal', function () { //var cashadvancecredit = $("#cashadvancecredit").attr("value"); //console.log(cashadvancecredit);                 $.getjson('json/resultscashissuancedepartment.json',  function(data){                   //var id = checkid;                  var output = '<table class="table table-bordered table-                               condensed"><tr>';                 output +='<th id="highlight"><font color="white">                           <center>employee id</center></font></th><th                            id="highlight"><font                            color="white"><center>name</center></font></th>                            </tr>';                 output += '<tr>';                           $.each(data, function(key, val){                           if(val.id == id){                 output += '<td><center>' + idier(val.id)+val.id +                            '</center></td>';                 output += '<td><center>' + val.name + '</center></td>';                            var department = val.department;                            var datecovered = val.datecovered;                            var explodedatecovered = datecovered.split("to");                            var name = val.name;                            var duration = val.duration;                            var fromstart = explodedatecovered[0];                            var toend = explodedatecovered[1];                            var cashadvancecredit = val.cashadvancecredit;                   output += '</tr></table>';                 output += '<form method="post"                             id="formsubmitdepartmentindividual"><div                             class="form-group row"><div                             class="col-xs-3"></div><div class="col-xs-6">                            <input type="text"                             name="cashadvancedepartmentonetimemodal"                             id="cashadvancemodaldepartment"                             class="form-control" placeholder = "less '+                             cashadvancecredit +'">                            </div></div>';                 output += '<div class="form-group row"><div class="col-                            xs-3"></div><div class="col-xs-6"><input                             type="date"                             name="datecashadvanceallonetimemodal"                             id="modaldepartmentdate" class="form-                            control" value = "'+today+'" readonly></div>                            </div>';                 output += '<div class="form-group row"><div class="col-                            xs-3"></div><div class="col-xs-6"><input                             type="hidden" name="function"                              class="form-control" value = "" ></div></div>';                 output += '<div class="form-group row"><div class="col-                            xs-3"></div><div class="col-xs-6"><input                             type="hidden" name="employeeid"                              class="form-control" value = "'+ id +'" ></div>                            </div>';                 output += '<div class="form-group row"><div class="col-                            xs-3"></div><div class="col-xs-6"><input                             type="hidden" name="type"                              class="form-control" value =                             "cashadvanceindivualdepartment" ></div></div>';                 output += '<div class="form-group row"><div class="col-                            xs-3"></div><div class="col-xs-6"><input                             type="hidden" name="department"                              class="form-control" value = "'+department+'" >                            </div></div>';                 output += '<div class="form-group row"><div class="col-                            xs-3"></div><div class="col-xs-6"><input                             type="hidden" name="fromstart"                              class="form-control" value = "'+fromstart+'" >                            </div></div>';                 output += '<div class="form-group row"><div class="col-                            xs-3"></div><div class="col-xs-6"><input                             type="hidden" name="toend"                              class="form-control" value = "'+toend+'" ></div>                            </div>';                 output += '<div class="form-group row"><div class="col-                            xs-3"></div><div class="col-xs-6"><input                             type="hidden" name="name"                              class="form-control" value = "'+name+'" ></div>                            </div>';                 output += '<div class="form-group row"><div class="col-                            xs-3"></div><div class="col-xs-6"><input                             type="hidden" name="duration"                              class="form-control" value = "'+duration+'" >                            </div></div>';                 output += '<div class="form-group row"><div class="col-                            xs-3"></div><div class="col-xs-6"><button                             type="button" class="btn btn-                            default" data-                            dismiss="modal">close</button>&nbsp<input                             type="submit"                             value="submit"                             id="submitmodaldepartmentindividual"                             name="btnsubmit"                             class="btn btn-primary"></div></div></form>';                      var x = cashadvancecredit;                     $('#dataondepartment').html(output);                     var value = $('#cashadvancemodaldepartment').val();                     console.log(value);                     //disable submit button if cash advance empty                     $('#submitmodaldepartmentindividual').prop("disabled",                      true);                     $('#cashadvancemodaldepartment').keyup(function(event){                     var input = $('#cashadvancemodaldepartment').val();                     var exp = new regexp(input);                      if(event.which != 8 &&                      isnan(string.fromcharcode(event.which))){                      $('#submitmodaldepartmentindividual').prop("disabled",                      true);                     }else if(($('#cashadvancemodaldepartment').val() == '')                      || (number($('#cashadvancemodaldepartment').val()) >                      number(cashadvancecredit)) ||                 (/^\s*$/.test($('#cashadvancemodaldepartment').val().trim())))       {              $('#submitmodaldepartmentindividual').prop("disabled", true);                        }                     else          if(($("#cashadvancemodaldepartment").val().replace(/ /g,'').length          != 0)){                 $('#submitmodaldepartmentindividual').prop("disabled",false);                      }                     else{        $('#submitmodaldepartmentindividual').prop("disabled",false);                     }                     console.log(cashadvancecredit);                     console.log($('#cashadvancemodaldepartment').val());                     });                     }                 });                 //marker        $('#formsubmitdepartmentindividual').on('submit',function(event){                     event.preventdefault();                     $.ajax({                             url:"ajaxpaymentprocessor.php",                             method:"post",          data:$('#formsubmitdepartmentindividual').serialize(),                             success: function(data){                           //$('#modalindividualdepartment').hide();                             $('#formsubmitdepartmentindividual')[0].reset();           $('#modalindividualdepartment').modal('hide');                                 $('#tabledepartment').html(data);                                 //$(".objects-list").html(data["html"]);                             }                       });                    });                      });              });            }); 

here landing page process ajax call

$type= $_post['type']; $cashadvances = array(); $x = 0; $employeeid = $_post['employeeid']; $prettyemployeeid = idier($_post['employeeid']).$_post['employeeid']; $duration = $_post['duration'];  <?php if($type == 'cashadvanceindivualdepartment'): ?>              <?php              //scope variable             $date = $_post['datecashadvanceallonetimemodal'];              $department = $_post['department'];             $name = $_post['name'];             $fromstart = $_post['fromstart'];             $toend = $_post['toend'];              $cashadvancecredit =   $_post['cashadvancedepartmentonetimemodal'];             //------end scope variable------//                if($querycashadvanceresult){              $output = '<h4><center>cash advance of <b><font                         color="red">'.$cashadvance.' php</font></b> made                         <b><font color="red">'.$employee['first_name'].'                       '.$employee['last_name'].'</font></b></center> </h4>';             $output .= '<table class="table table-bordered table-condensed"                          id="departmenttable">                         <tr bgcolor = "#2c3e50">                         <th><font color="white"> company id</th>                         <th><font color="white">department</th>                         <th><font color="white">name</th>                         <th><font color="white">date covered</th>                         <th><font color="white">cash advance</th>                        </tr>';             $data = array();                 while($result = mysqli_fetch_array($resultquerydepartment)){                     $cashadvances[] += $result['company_id'];                 $data[] = array('id'=> $result['company_id'],                     'department'=>$result['department'],                     'name'=>$result['name'],                     'datecovered' =>$datecovered,                     'cashadvancecredit' =>                      $resultattendancepayroll['salary'],                     'duration' => 'weekly'                  );                 $json_data = json_encode($data);                 $mydir = 'json';                  if(!file_exists($mydir)){                     $oldmask = umask(0);  // helpful when used in linux                     server                     mkdir($mydir, 0777);                 }               file_put_contents($mydir.'/resultscashissuancedepartment.json',               $json_data);                     $output .='<tr>                            <td><p    id="subukanulit">'.idier($result['company_id']).$result['company_id'].                '</p></td>                      <td>'. $result['department'].'</td>                      <td>'.$result['name'].'</td>                      <td>'.prettydate($fromstart)."                       ".prettydate($toend).'</td>                       <td>                         <a data-statename="'.$result['company_id'].'">                <button type="button"  id="modalindividualondepartment"                 value="'.$result['company_id'].'" class="btn btn-primary              edit_data"   data-toggle="modal" data-             target="#modalindividualdepartment"                              '.          ((($resultcashadvancebyindividualondepartment) ||           ($resultfullypaidindividualondepartment ==            '0'))?'disabled':'').'>click pay cash advance</button></a>                            </td>                 </tr>';                 $x++;             }             $output .='</table></div>';             echo $output;             ?>              <?php }?>              <?php else: ?>                 <?php if($type == 'cashadvancedepartmentonetime'): ?>                 <?php                               $department = $_post['department'];                              $duration = $_post['duration'];                              $fromstart = $_post['fromstartdepartment'];                              $toend = $_post['toenddepartment'];                              $cashadvance =                               $_post['cashadvancedepartmentonetime'];                              $employeeid = $_post['employeeid'];                              $employeeid =                               unserialize(base64_decode($employeeid));                              $dateofpayment =         $_post['datecashadvancedepartment'];                              $counter = sizeof($employeeid) - 1;                              $starter = '';                              for( $starter = 0 ; $counter >= $starter ;              $starter++ ){                                  $id = $employeeid[$starter];                                  $id = idier($employeeid[$starter]).$id;                                  $idnotprocessed = $employeeid[$starter];                                  //select employee_profile                                  $queryname = "select *         employee_profile company_id = '$idnotprocessed' order                                                id desc limit 1";                                  $resulqueryname = $db->query($queryname);                                  $resultname =         mysqli_fetch_array($resulqueryname);                                  $name = $resultname['first_name']."         ".$resultname['last_name'];                                  //end select employee profile                                  //select department                                     $querydepartmentcashadvance = "select          employee_profile.id, employee_profile.company_id,          company_profile.department                                                                               employee_profile inner join company_profile           employee_profile.company_id = company_profile.company_id                                                                     ,            employee_profile.company_id ='$idnotprocessed' ";                                     $resultquerydepartmentcashadvance = $db-           >query($querydepartmentcashadvance);                                     $resultdepartmentcashadvance =            mysqli_fetch_array($resultquerydepartmentcashadvance);                                     $department =            $resultdepartmentcashadvance['department'];                                  //end select department                                  //check existing record                                  $queryexistingrecord = "select *             cash_advance company_id = '$id' , date >= '$fromstart'                                                          , date <=             '$toend'";                                  $resultexistingrecord = $db-            >query($queryexistingrecord);                                  $existingrecord =           mysqli_fetch_array($resultexistingrecord);                                   if(empty($existingrecord)){                                      //insert cash advance 1 time                                      $querycashadvancedepartment = "insert          cash_advance(company_id, name, department,advance_payment,           date, duration)                                      values('$id', '$name',         '$department','$cashadvance', '$dateofpayment', '$duration')";                                      $resultquerycashadvancedepartment =          $db->query($querycashadvancedepartment);                                      //end insert cash advance 1 time                                  }                                  //end checking existing record                               }                              //------query department-------//                              $querydepartment = "select        attendance_payroll.company_id, attendance_payroll.name,         attendance_payroll.date_identifier, company_profile.department                              attendance_payroll inner join         company_profile on company_profile.company_id =         attendance_payroll.company_id                              company_profile.department =        '$department' , attendance_payroll.date_identifier >='$fromstart'         , attendance_payroll.date_identifier <= '$toend'                              group attendance_payroll.company_id order         attendance_payroll.company_id ";                              $resultquerydepartment = $db-        >query($querydepartment);                              //-----end query department----//                              $output = '<h4><center>cash advance of <b><font       color="red">'.$cashadvance.' php</font></b> made <b><font       color="red">all</font></b></center> </h4>';                              $output .= '<table class="table table-bordered       table-condensed" id="departmenttable">       <tr bgcolor = "#2c3e50">            <th><font color="white"> company id</th>            <th><font color="white">department</th>            <th><font color="white">name</th>            <th><font color="white">date covered</th>            <th><font color="white">cash advance</th>            </tr>';                              //$data = array();                              //$datecovered = $fromstart.'to'.$toend;                               while($result =                 mysqli_fetch_array($resultquerydepartment)){             //check cash advance per individual if existing                                  $employeeid =                idier($result['company_id']).$result['company_id'];                                  $querycashadvancebyindividualondepartment =            "select * cash_advance duration = 'weekly'                                  , company_id = '$employeeid' , date >=              '$fromstart'                                  , date <= '$toend'";         $resultquerycashadvancebyindividualondepartment = $db-         >query($querycashadvancebyindividualondepartment);         $resultcashadvancebyindividualondepartment =          mysqli_fetch_array($resultquerycashadvancebyindividualondepartment);                                  //end checking     //check if paid , not qualified cash advance         $queryfullypaidindividualondepartment = "select *          attendance_payroll company_id = '$employeeid'                                  , date_identifier >='$fromstart' ,          date_identifier <='$toend'                                  , payment_status = '1'";                                  $resultqueryfullypaidindividualondepartment            = $db->query($queryfullypaidindividualondepartment);                                  $resultfullypaidindividualondepartment =             mysqli_num_rows($resultqueryfullypaidindividualondepartment);                                  //end checking                                  $output .='<tr>                            <td><p     id="subukanulit">'.idier($result['company_id']).$result['company_id'].'</p>    </td>                            <td>'. $result['department'].'</td>                            <td>'.$result['name'].'</td>                            <td>'.prettydate($fromstart)."   ".prettydate($toend).'</td>                            <td>                            <a data-statename="'.$result['company_id'].'">    <button type="button"  id="modalindividualondepartment"     value="'.$result['company_id'].'" class="btn btn-primary edit_data"      data-toggle="modal" data-target="#modalindividualdepartment"                              '.   ((($resultcashadvancebyindividualondepartment) ||    ($resultfullypaidindividualondepartment == '0'))?'disabled':'').'>click     pay cash advance</button></a>                            </td>                 </tr>';                                  $x++;                              }                              $output .='</table></div>';                              echo $output;                              ?>                                 <!-- validity of pay button -->                                     <?php                                            $queryattendancepayrollcompare =      "select attendance_payroll.id, attendance_payroll.company_id,       attendance_payroll.name, company_profile.department         attendance_payroll inner join company_profile       attendance_payroll.company_id = company_profile.company_id      , date_identifier >= '$fromstart' , date_identifier <= '$toend' ,      company_profile.department = '$department'      group attendance_payroll.company_id order      attendance_payroll.company_id";     $resultattendancepayrollcompare = $db-     >query($queryattendancepayrollcompare);     $resultattendancepayrollcomparecount =     mysqli_num_rows($resultattendancepayrollcompare);     $querycashadvancecompare = "select * cash_advance duration =    'weekly' , department = '$department'                                                                       ,     date >= '$fromstart' , date <='$toend' group company_id order     company_id";                                           $resultquerycashadvancecompare =     $db->query($querycashadvancecompare);                                           $resultcashadvancecomparecount =     mysqli_num_rows($resultquerycashadvancecompare);                                        ?>                           <!-- end validity of payment button -->                              <?php                          ?>                 <?php endif; ?> 

please , many :)

found answer folks,

i need include of function hidden modal on landing page because once refreshed, reading not on same page anymore instead, data on landing page..

thanks anyway :)





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -