Error fetching page data with AJAX

0

I'm trying to pull content through ajax but I'm not getting it, nothing appears in RecebeAjax.

HTML:

<a href="#portfolioModal54" class="portfolio-link" 
data-toggle="modal" id="executaAjax" value="Executa ajax">
    <img src="<?php echo "$imageM"?>" alt="project 2">
    <div class="fundo-port">
        <h1><?php echo "$tipo"?></h1>
        <h2><?php echo "$nome"?></h2>
     </div>
</a>

<div class="wrap RecebeAjax">
</div>

ajax.js:

$(document).ready(function(){      
   $('#executaAjax').click(function(){
      $.ajax({
          url: "ajax.php",
          success:(function(data){
               $('.RecebeAjax').html(data);
          }
   });      
});

ajax.php (content to be pulled)

<div id="text-proj">
   <h1 style="font-size: 35px;">Mania de Lanches</h1>
      <img class="linhaP" src="images/linha.png" style="padding-top: 15px;padding-left: 13px;    margin-bottom: 20px;"><img class="linhaPM" src="images/linha.png">
    <h1 style="margin-bottom: 20px;font-size: px;">Rede Social</h1><div id="prop3">

     <h2>Mídia virtual desenvolvida para a lanchonete Mania de Lanches divulgando promoções e datas especiais para atrair o consumo e interesse de seus clientes.
     </h2>
</div>
<div id="img-proj">
   <img src="images/port/full/markedigi/rede/mania/post.jpg">
</div>
    
asked by anonymous 14.01.2016 / 20:46

2 answers

1

Considering that you only want to get an html helper $.load solves your problem, try using the implementation below:

$(document).ready(function(){      
   $('#executaAjax').click(function(){
      $(".RecebeAjax").load("ajax.php");
   });      
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><ahref="#portfolioModal54" class="portfolio-link" data-toggle="modal" id="executaAjax" value="Executa ajax">
  <img src="http://placehold.it/350x150"alt="project 2">
  <div class="fundo-port">
    <h1>Tipo</h1>
    <h2>Nome</h2>
  </div>
</a>

<div class="wrap RecebeAjax">
</div>
    
15.01.2016 / 14:12
2

See if it helps:

$(document).ready(function(){      
   $('#executaAjax').click(function(){
      $.ajax({
          type: "GET",
          url: "ajax.php",
          async: true,
          dataType: 'json',
          success:(function(data){
               $('.RecebeAjax').html(data);
          }
   });      
});
    
14.01.2016 / 21:19