我在使用Jquery Ajax和PHP时遇到了问题。我正在尝试将数据从我的脚本发送到一个 php 文件,该文件应该进一步处理数据。但是我没有从 php 那里得到任何回应...
该网页:
<form id="form-comment">
<textarea id="popup-text" name="comment-text" placeholder="Skriv din kommentar her"></textarea>
<input id="popup-close" type="button" value="Annuller"/>
<input id="popup-ok" type="submit" value="OK"/>
</form>
Jquery:
$('#form-comment').submit(function(event){
var comment = $('#popup-text').val()
var c_pdf = $('#current-pdf').attr('data')
var pdf_array = c_pdf.split("/")
var post_data = pdf_array[1].trim() + " " + pdf_array[2].slice(0,-4)
$.ajax({
url: 'php/handler-comment.php',
type: "post",
data: post_data,
succes: function(response){
console.log("PHP responded with: " + response)
}
}).fail(function(){
console.log("Fail")
})
})
.PHP
echo "Test";
失败函数不会触发,但 succes 函数从不打印任何内容。我可以在 ajax 之前和之后.log控制台数据。你能帮我找到问题吗?谢谢。
success
单词有错误:
$.ajax({
url: 'php/handler-comment.php',
type: "post",
data: post_data,
success: function(response){
console.log("PHP responded with: " + response)
}
}).fail(function(){
console.log("Fail")
})