Reputation: 103
Why isn't my function get called? I didn't make any syntax errors.
Also, return false
isn't the problem. My function should still get called.
<form onsubmit='createComment(commentType, currentQuestionID, $("#addCommentAuthor").val(), $("#addCommentEmail").val(), $("#addCommentContent").val(), $("#addCommentDate").val());return false;' method='POST'>
var createComment = function(commentType, questionId, author, email, content, date) {
console.log('asd')
$.ajax({
url: "controller.php",
type: 'POST',
data: {
commentType: commentType,
questionId: questionId,
add_comment_author: author,
add_comment_email: email,
add_comment_content: content,
add_comment_date: date
},
success: function(data) {
console.log(data)
}
})
}
Upvotes: 2
Views: 100
Reputation: 61
You should change the function name "createComment" as it is global method document.createComment()
Upvotes: 2