Sam
Sam

Reputation: 1381

how to refresh the div content without the page reloads

I have the modal with form on click of save it saves in the temporary page and the modal has to close the values should get displayed in the div content.now it is working fine but when the page reloads the content is displaying.i don't want to reload the page

html code:

<div class="content">

  <?php if($load_data): ?>

    <?php foreach($load_data as $data): ?>
      <div class="row modal_bg">
        <div class="col-md-3">
          <span class="jd_name"><?php echo $data->first_name; ?></span>
          <span class="jd_name" ><?php echo $data->last_name; ?></span>
          <p class="loc"><?php echo $data->location; ?></p>
        </div>

      </div>
    <?php endforeach; ?>
  <?php endif; ?>

</div>

ajax code:

jQuery.ajax(
  {
    type: "POST",
    url: "<?php echo base_url(); ?>" + "page/datapage/",
    data: formData,
    processData: false,
    contentType: false,
    success: function(res) 
      {
        $('#myModal').modal('hide');
        console.log(res);
        if(res)
        {

          url:"<?php echo base_url(); ?>page/datapage/<?php echo $per->id;  ?>";

        }
      },
    error: function(errResponse) 
      {
        console.log(errResponse);
      }
  });

how to solve this issue ,without page reload i want to display the content.can anyone suggest me how to do.

Upvotes: 0

Views: 83

Answers (1)

Rahul
Rahul

Reputation: 1615

you need to use html();

success: function(res) 
      {
$('#yourTargetId').html(res);

Upvotes: 1

Related Questions