How to show content by default in jquery without action without click and event ajax

Description

How to Pass value to other file in php jquery ajax and how to get return value in ajax php .Create a function and pass ID in div How to crate a function in ajax and javascrit . Ajax used for fatch and display the content in fast way. and submit the text without refresh page and acces the only content .

Create a two File in Php 

index.php and ajaxlist.php

index.php

<script type = "text/javascript" >

$(document).ready(function(){

<!------show to content form---------->

  function showComment(){  

   var phonenocomment = $("#phoncom").val();   

                      $.ajax({

                        type:"post",

                        url:"ajaxlist.php",

data:"phonenocomment="+phonenocomment+"&action=showcomment",

                      // data:"action=showcomment",

                        success:function(data){

                             $("#dismsgcomment").html(data);

                        }

                      });

                    }  

                    showCommentlist();

 

<!------insert content---------->

$("#subcomment").click(function() {  

         var msgcommentlist = $("#msgcommentlist").val();

          var sirstaff = $("#sirstaff").val();

         var phonenocomment = $("#phonenocomment").val();

var toponlineq = $("#toponlineq").val(); 

  var topqualicommnt = $("#inputquali1").val(); 

  var statusalluponrp = $("#statusalluponrp").val();

 

/*$.post("action.php",{name:name,email:emailid,phoneno:phoneno},function(data){

$("#result").html(data);

});*/    //&topnamecomment="+topnamecomment+"&topcourscomment="+topcourscomment+"&topcitycommnt="+topcitycommnt+"        

 

 

$.ajax({

url:'ajaxlist.php',

data:"msgcommentlist="+msgcommentlist+"&calendar_datePicker1="&statusalluponrp="+statusalluponrp+"&action=addcomment",  

//data:{name:name,email:emailid,phoneno:phoneno,action:addcomment},

type:'POST',

success:function(data){

$("#result").html(data);

 showCommentlist();

}

 

});

 

           else  

           {  

                $('#result').html('');                 

           }  

 <!------ Condition apply on Text area empty-------->

 document.getElementById("msgcommentlist").value = "";

});

});

</script>

 

 

How to display return information in div and id

 

<div class="col-lg-12" id="dismsgcomment" style="color:#000000;  padding: 14px 0px;"></div> // in div show dismsgcomment comment data

        <div id="result" style="color:#D80D0D" ></div>  // in div show result comment data

 

 

 

ajaxlist.php

 

 

<?php

$sirstaff = $_POST['sirstaff'];

$msgcommentlist = $_POST['msgcommentlist'];

$phonenocomment = $_POST['phonenocomment'];

$toponlineq=$_POST["toponlineq"];

$topqualicommnt=$_POST["topqualicommnt"];

$addcl = $_POST['statusalluponrp'];

 if($action=="showcomment"){ ?> <table class="table >

                                                <thead>

                                                        <th style="font-size:12px"> Phone No</th>

<th> Name</th> 

<th> Course </th>

     <th> edu </th>                                                   

                                                    </tr>

                                                </thead>

                                                <tbody>

<?php

     $show=mysql_query("Select * from list WHERE mobile like '%".$phonelist."%' order by id desc LIMIT 0,10");

 while($row=mysql_fetch_array($show)){ 

?>

<tr>

<th style="font-size:12px"><?php echo $row['mobile']; ?></th> 

<td><?php echo $row['name']; ?></td>

<td><?php echo $row['coursetop']; ?></td>                                                   

                                                    </tr>

<?php   }  ?>

                                                </tbody>

                                            </table>

 

 <?php 

  } 

  

    else if($action=="addcomment"){

echo "insert into callcomment(staffname,msgcomment,phoneno,onlinestatus,statusst) values ('$sirstaff','$msgcommentlist','$toponlineq','$statusst')"; 

echo "* Data insert Completed *";

}else{

 echo "Followup Completed";

}

 

}

  

  

?>

 

 

 

 

 

 

 

<script type = "text/javascript" >

// Jquery synatx

//$("#country_name").click(function() { 

$(document).ready(function(){

<!------show to content form---------->

  

  //  var phonenocomment = $("#country_name").val();