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 writeget
parameter in url (action=post). - when post data comment name, must data name in
php
($_post['comment']
). - when use
ajax
shouldn't usefunction
inphp
or callfunction
after defintion. - when use
ajax
mustprint
orecho
data inphp
file display in post result.
Comments
Post a Comment