您好,我正在一个php java submithing评论系统,现在我有一个问题,我不能单独解决。 我只想问我怎么可以让这个PHP和JavaScript提交表单与更改表单名称?
$('#addCommentForm'+x).submit(function(e){
DO something here
}
addCommentForm有很多的数字后,是这样的:addCommentForm1 addCommentForm2 addCommentForm3 addCommentForm4和不断上升。那么我怎么能让这个改变名字的工作在java中进行工作呢?
var x = $_POST['comentonpost'];
的$ _ POST是从这里来的:
<script type='text/javascript'> var $_POST = <?php echo !empty($_POST)?json_encode($_POST):'null';?>; </script>
X - 是我从HTML形式得到了submiting的信息岗位价值,但如果我按一次一个评论提交JavaScript是只为这个评论工作,直到页面刷新。
在这里你可以看到--- http://www.youtube.com/watch?v=okqQsPCZqVE
这里是整个Java脚本:
$(document).ready(function(){
var x = $_POST['comentonpost'];
/* The following code is executed once the DOM is loaded */
/* This flag will prevent multiple comment submits: */
var working = false;
/* Listening for the submit event of the form: */
$('#addCommentForm'+x).submit(function(e){
e.preventDefault();
if(working) return false;
working = true;
$('#submit').val('Working..');
$('span.error').remove();
/* Sending the form fileds to submit.php: */
$.post('comment.submit.php',$(this).serialize(),function(msg){
working = false;
$('#submit').val('Submit');
/*
/ If the insert was successful, add the comment
/ below the last one on the page with a slideDown effect
/*/
$(msg.html).hide().insertBefore('#addCommentContainer'+x).slideDown();
},'json');
});
});
所以,请告诉我,我怎么能解决这个问题,让这个脚本运作良好而无需刷新页面?
此代码不是Java,它是Javascript。尽管名称相似,但它不是同一种语言。 –
另外,您将Javascript和PHP('$ _POST')混合在一起。这没有任何意义。 –
也许这是有道理的: –