0

I want to display emoticon by click on a tab. Here my browser display: ajax sent data to smileysmore.php as action:smileysboxmore Sid:888 but cannot display any response data.

I am working new with php function. Please give me a guideline.

Html:

<ul class="nav nav-tabs">
    <li class="active"><a href="#sectionA">A</a></li>
    <li><a class="sm2" href="javascript: void(0)">B</a></li>
</ul>
<div class="tab-content">
    <div id="sectionA">
    <div id="sectionB">
</div>

Ajax:

$(document).ready(function(){
    $('li').on("click", 'a.sm2', function(e){
    var id = 888;
        $.ajax({
        type: "POST", 
        url: "../smileysmore.php", 
        data: "action=smileysboxmore&Sid="+ id,
            complete: function(data){
            $('#sectionA').hide();
            $('#sectionB').fadeIn().html(data);
            }
        });
    });
});

smileysmore.php

function smileysboxmore($Sid){
echo'<img src="../smile.gif" alt=":)" class="embtno" id="'.$Sid.'" />
     <img src="../sad.gif" alt=":(" class="embtno" id="'.$Sid.'" />
     <img src="../cool.gif" alt="B-)" class="embtno" id="'.$Sid.'" />';
}
2
  • What is the code of smileysmore.php file Commented Aug 24, 2015 at 13:47
  • Is that the entire contents of smileysmore.php? If so, then you have no request handling code to actually call the function Commented Aug 24, 2015 at 13:50

1 Answer 1

2

in your ajax change complete to success

$(document).ready(function(){
    $('li').on("click", 'a.sm2', function(e){
    var id = 888;
        $.ajax({
        type: "POST", 
        url: "../smileysmore.php", 
        data: "action=smileysboxmore&Sid="+ id,
            success: function(data){
            $('#sectionA').hide();
            $('#sectionB').fadeIn().html(data);
            }
        });
    });
});

and in smileysmore.php

smileysboxrepmore($_POST['Sid']);
function smileysboxrepmore($Sid){
echo'<img src="../smile.gif" alt=":)" class="embtno" id="'.$Sid.'" />
     <img src="../sad.gif" alt=":(" class="embtno" id="'.$Sid.'" />
     <img src="../cool.gif" alt="B-)" class="embtno" id="'.$Sid.'" />';
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.