私は現在、HTMLフォームからPHPフォームにいくつかの情報を投稿するようにAjaxを作ろうとしています。
さて、今私は「ajax.comment.php」ページに何が起こったのかを伝える違いコードを作成しました。
成功したか失敗したかのように。
私は今、私のajaxを作りたいと思っています。印刷されたhtmlが何であるかを確認してください。そして、それを処理します.. if (Printed HTML == "1") {Then do something} のように。
どうやってやるの?
私の次のJavaScriptは次のとおりです。
var name = document.comment.name.value;
var email = document.comment.email.value;
var website = document.comment.website.value;
var message = document.comment.message.value;
var id = document.comment.id.value;
$.ajax({
type: "POST",
url: "ajax.addcomment.php",
data: "name="+name+"&email="+email+"&website="+website+"&message="+message+"&id="+id,
beforeSend: function() {
// Action before sending data
},
success: function(returned_html) {
// Action after sending data, where the returned_html var is the returned html text by the php
}
});