I am having an issue with Jquery Ajax and PHP. I am trying to send data from my script to a php file which should handle the data further. But I am not getting any response from the php...
The html:
<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>
The 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";
The fail function is not triggering, but the succes function never prints anything. I can console.log data before and after the ajax. Can you help me find the problem? Thanks.
You have an error with the success
word :
$.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")
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.