This JS is giving me some problems. Specifically FF3.5 is saying there is Error: missing ; before statement
and its pointing at the 'comsn=' + comsn
section. I know enough js to get myself into trouble, but specifics, im not there yet. Any ideas?
这个JS给我带来了一些问题。具体来说,FF3.5说有错误:缺失;在语句之前,它指向'comsn=' + comsn部分。我知道有足够多的js让我陷入麻烦,但具体来说,我还没到那一步。什么好主意吗?
<script type="text/javascript" >
$(function () {
$(".submit").click(function () {
var comsn = $("#comsn").val();
var comrn = $("#comrn").val();
var compic = $("#compic").val();
var comment = $("#comment").val();
var eventid = $("#eventid").val();
var comuserid = $("#comuserid").val();
var owner = $("#ownerid").val();
var dataString = 'comsn=' + comsn '&comrn=' + comrn '&compic=' + compic '&comment=' + comment '&eventid=' + eventid '&comuserid=' + comuserid '&owner=' + owner;
if (comment == '') {
alert('Must Type Comment to Post Comment');
}else{
$("#flash").show();
$("#flash").fadeIn(400).html('<img src="assets/uploading.gif" />Loading Comment...');
$.ajax({
type: "POST",
url: "comments_post.php",
data: dataString,
cache: false,
success: function (html) {
$("ol#update").prepend(html);
$("ol#update li:last").fadeIn("slow");
$("#flash").hide();
}
});
}return false;
});
});
</script>
3 个解决方案
#1
1
var dataString = 'comsn=' + comsn + '&comrn=' + comrn + '&compic=' + compic + '&comment=' + comment + '&eventid=' + eventid '&comuserid=' + comuserid + '&owner=' + owner;
You've got a lot of missing +
.
你有很多东西不见了。
Also jquery have a method called serialize which do the same think you are doing by hand probably worth to give a try.
此外,jquery还有一个名为serialize的方法,它可以实现与手工操作相同的功能,可能值得一试。
#2
1
You have missing +
signs in your concatenation:
您在连接中缺少+符号:
var dataString = 'comsn=' + comsn + '&comrn=' + comrn +
'&compic=' + compic + '&comment=' + comment +
'&eventid=' + eventid + '&comuserid=' + comuserid +
'&owner=' + owner;
However if you want to get all your form element values in a string of data, you could use the Ajax/serialize method:
但是,如果您想在一串数据中获取所有的表单元素值,您可以使用Ajax/serialize方法:
var dataString = $("#formId").serialize();
#3
1
Your missing some +s
你缺少一些+ s
+ comrn '&compic='...
should be
应该是
+ comrn + '&compic='...
#1
1
var dataString = 'comsn=' + comsn + '&comrn=' + comrn + '&compic=' + compic + '&comment=' + comment + '&eventid=' + eventid '&comuserid=' + comuserid + '&owner=' + owner;
You've got a lot of missing +
.
你有很多东西不见了。
Also jquery have a method called serialize which do the same think you are doing by hand probably worth to give a try.
此外,jquery还有一个名为serialize的方法,它可以实现与手工操作相同的功能,可能值得一试。
#2
1
You have missing +
signs in your concatenation:
您在连接中缺少+符号:
var dataString = 'comsn=' + comsn + '&comrn=' + comrn +
'&compic=' + compic + '&comment=' + comment +
'&eventid=' + eventid + '&comuserid=' + comuserid +
'&owner=' + owner;
However if you want to get all your form element values in a string of data, you could use the Ajax/serialize method:
但是,如果您想在一串数据中获取所有的表单元素值,您可以使用Ajax/serialize方法:
var dataString = $("#formId").serialize();
#3
1
Your missing some +s
你缺少一些+ s
+ comrn '&compic='...
should be
应该是
+ comrn + '&compic='...