Answers for "ajax response return html page"

2

ajax response returns entire page

Use condition to verify if $_POST empty in you main page or index.php to not send the whole page in response ajax
and verif your AJAX URL
 $.ajax({
             type:"POST",
             url:"http://mywebsite.com/php/send_email.php",
   .......
   
index.php
------------------------
<?php 
if(empty($_POST)){ ?>

//
<html>
the header pages
the body
the include pages
the scripts pages
the footer
<?php } ?>
Posted by: Guest on October-30-2020
2

ajax get html response

//your jquery code will be like this:
$.ajax({
      type: 'POST',
      url: $url,
      data: new FormData(this),
      dataType: 'json',
      contentType: false,
      processData:false,//this is a must
      success: function(response){ 
      		$('your_selector').html(response);
      }
});

//php code will be like this
echo '<div>some html code</div>';
die();
Posted by: Guest on June-11-2021

Browse Popular Code Answers by Language