The following warnings occurred:
Warning [2] Undefined array key "threadviews_countguests" - Line: 745 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/showthread.php 745 errorHandler->error_callback
Warning [2] Undefined array key "allowautourl" - Line: 584 - File: inc/class_parser.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/class_parser.php 584 errorHandler->error_callback
/inc/class_parser.php 228 postParser->parse_mycode
/inc/functions_post.php 830 postParser->parse_message
/showthread.php 1121 build_postbit
Warning [2] Undefined array key "allowautourl" - Line: 584 - File: inc/class_parser.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/class_parser.php 584 errorHandler->error_callback
/inc/class_parser.php 228 postParser->parse_mycode
/inc/functions_post.php 830 postParser->parse_message
/showthread.php 1121 build_postbit
Warning [2] Undefined array key "allowautourl" - Line: 584 - File: inc/class_parser.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/class_parser.php 584 errorHandler->error_callback
/inc/class_parser.php 228 postParser->parse_mycode
/inc/functions_post.php 830 postParser->parse_message
/showthread.php 1121 build_postbit
Warning [2] Undefined property: MyLanguage::$thread_modes - Line: 46 - File: showthread.php(1650) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/showthread.php(1650) : eval()'d code 46 errorHandler->error_callback
/showthread.php 1650 eval




Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QUESTION How to use Ajax and retrieve data
#1
Hello guys, I have currently got a list of items displaying, which when clicked should reveal a modal with further details. Now, I have got the modal showing part to work via:

Code:
<div class="portfolio-modal modal fade" id="job-description" tabindex="-1" role="dialog" aria-hidden="true">
  <div class="modal-content">
    <div class="close-modal" data-dismiss="modal">
      <div class="lr">
        <div class="rl"> </div>
      </div>
    </div>
    <div class="container">
      <div class="row">
        <div class="col-lg-8 col-lg-offset-2">
          <div class="modal-body">
            <!-- Project Details Go Here -->
            <h2 class="modal-title" id="exampleModalLabel"></h2>
            <p class="item-intro">Lorem ipsum dolor sit amet consectetur.</p>        
            <?php $jobid = "<p class='jobid'></p>"; ?>
            <p><?php include_job_details($jobid);?></p>
            <button type="button" class="btn btn-primary" data-dismiss="modal"><i class="fa fa-times"></i> Close Project</button>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>


Then I have a custom plugin with this function, which should get the correct further details and display them:

PHP Code:
function include_job_details($thejob){
    echo(
$thejob); 
    global 
$jobs_list;
    
$jobs_list read_jobs_from_file();
        
//find the job details to output
        
$iterator 0;
        
$job = array();
        for (
$iterator 0$iterator count($jobs_list); $iterator++){
            
$job $jobs_list[$iterator];
            if (
$job['jobID'] == $thejob){
                break;
            }
        }
        
?>    
        <div class="job-listing-middle">
            <span class="job-title"><?php echo $job['title'];?></span><span class="job-location"><?php echo $job['location'];?></span>
            <span class="job-salary"><?php echo $job['salary'];?></span>
            <span class="job-description" style="margin-top:5px"><?php echo $job['description'];?></span>
        </div>
        <div class="job-listing-button">
            <span class="job-tag">Click to apply online</span>
            <div class="job-button-container">
                <a class="job-apply-button" href="./<?php printf("./apply-for-a-job?jobID=%s&title=%s"$_GET['jobID'], urlencode($job['title']));  ?>" title="">
                    <span>Apply Online</span>
                </a>
            </div>
        </div> 
        <?php
        



I call this function in the modal code above. The p tag with the class jobid is where I am setting the specific list item clicked and the variable value for $thejob via:

Code:
$('#job-description').on('show.bs.modal', function (event) {
  var button = $(event.relatedTarget) // Button that triggered the modal
  var recipient = button.data('id') // Extract info from data-* attributes
  // If necessary, you could initiate an AJAX request here (and then do the updating in a callback).
  // Update the modal's content. We'll use jQuery here, but you could use a data binding library or other methods instead.
  var modal = $(this)
  modal.find('.jobid').text(recipient)
  
})


As you probably can tell very confusing, I just want to get the modal that pops up populated with the related information. The function works, I just need help on how I can set the variable $thejob or use ajax ?
Reply
#2
I would use plugin Extra Router, or create a template file, create page ajax and then call it like domain.com/ajax?jobid=123 ..and you can call the function directly in ajax template file (but it's not ideal, Extra Router is much better option)
Reply
#3
(2016-06-01, 23:10:13)morvy Wrote: I would use plugin Extra Router, or create a template file, create page ajax and then call it like domain.com/ajax?jobid=123 ..and you can call the function directly in ajax template file (but it's not ideal, Extra Router is much better option)

I got it to work in the end via ajax.
Reply




Users browsing this thread: 1 Guest(s)