javascript - Pass value from a table into a function using jquery -


i trying pass variable thecode, in table using jquery function named getcomments(). code has following. first have jquery script this:

$(document).ready(function(){                                $("#comment_process").click(function(){         if($("#comment_text").val() != ""){           $('.post_loader').show();             $.post("comments_business.php?action=post", {                  comment: $("#comment_text").val()              }, function(data) {                 $(".comments").hide().html(data).fadein('slow');                 $("#comment_text").val("");                 $('.post_loader').hide();             });         }      });    });  

next have following script html , php:

<!--- more code @ top----> <?php $auto = $profile_data_business['business_code'];  ?> <table>                                  <textarea rows="3"  id="comment_text" placeholder="share update."></textarea>     <input type="" id="comment_code" name="thecode"  value="<?php echo $auto; ?>" />                                 <input type="button" id="comment_process" />  </table> <div class="comments"><?php include_once("comments_business.php");?>   </div>  

the page named comments_business.php includes function following:

<?php function getcomments(){          $session_user_id = $_session['user_id'];     $comments = "";     // can't variable $thisemail     $thisemail = mysql_real_escape_string($_post['thecode']);     $sql = mysql_query("select * comments_business ( `flag`=0 , `user`='$thisemail' ,  `comments_id` not in (select `comments_id` `hide_comment_business` `user`='$session_user_id') ) order comment_date desc limit 40") or die (mysql_error());     //more code here                 return $comments;        }    ?> 

any idea how should change jquery code able pass $thisemail variable getcomments() function?

  • when use $.post don't need write get parameter in url (action=post).
  • when post data comment name, must data name in php ($_post['comment']).
  • when use ajax shouldn't use function in php or call function after defintion.
  • when use ajax must print or echo data in php file display in post result.

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -